Detect when interface is disabled / disabled in Twisted Python

I am creating a multicast listener using the multicast features provided by the Twisted Framework. So far, so good. However, I would like to know if the interface is not running when the app is started (which causes the MulticastJoinError ) and wait it should be ready to subscribe to the group or in case of unexpected network disconnection, get some kind of notification so I can terminate execute or process it in any other way.

class Listener(DatagramProtocol):
   def startProtocol(self):
      try:
          self.transport.joinGroup(MULTICAST_ADDR)
      except MulticastJoinError:
          #handle multicast error


reactor.listenMulticast(conf.PORT, Listener(), listenMultiple=True)

      

Thanks in advance!

+3
python twisted


source to share


No one has answered this question yet

Check out similar questions:

5504
Does Python have a ternary conditional operator?
5231
What are metaclasses in Python?
5116
How can I check if a file exists without exceptions?
4473
Calling an external command in Python
3790
How can I safely create a subdirectory?
3602
Does Python have a substring method "contains"?
3119
What is the difference between Python list methods that are appended and expanded?
2849
How to make a flat list from a list of lists?
2818
Finding the index of an element by specifying the list that contains it in Python
2568
How to find the current time in Python


Loading...
X
Show
Funny
Dev
Pics