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


source to share