Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling stop() on MDNSEngine causes AttributeError #6

Closed
andrewbonney opened this issue Dec 20, 2017 · 1 comment
Closed

Calling stop() on MDNSEngine causes AttributeError #6

andrewbonney opened this issue Dec 20, 2017 · 1 comment

Comments

@andrewbonney
Copy link
Contributor

>>> 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
Copy link
Contributor

jamesba commented Dec 20, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants