Calling stop() on MDNSEngine causes AttributeError
Closed this issue · 1 comments
andrewbonney commented
>>> from nmoscommon.mdns import MDNSEngine
>>> mdns = MDNSEngine()
>>> mdns.start()
>>> mdns.stop()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/nmoscommon/mdns/avahidbus.py", line 52, in stop
self._mainloop.quit()
AttributeError: 'MDNSEngine' object has no attribute '_mainloop'
jamesba commented
try the following:
>>> from nmoscommon.mdns import MDNSEngine
>>> import gevent
>>> mdns = MDNSEngine()
>>> mdns.start()
>>> gevent.sleep(0)
>>> mdns.stop()
>>>
This is a gotcha with using gevent based libraries from the command prompt: you need to explicitly yield control to allow other greenlets (threads, essentially) an opportunity to run. gevent.sleep(0) does this by sleeping for 0 seconds.