2016-04-20 13:10:56 |
Lucian Petrut |
description |
PyMI subscribes to event providers, setting a callback that will be invoked when an event arrives. When called, the event watcher will block until an event is retrieved. A threading.Event is used internally by PyMI for the event waiting workflow.
The issue is that the threading module will be monkey patched by eventlet. The event callback is performed from a different thread, so attempting to set the event for which the event watcher waits will some times raise the "error: cannot switch to a different thread" greenlet exception, thus breaking the event listener.
This issue can be fixed at the os-win level, without having PyMI to know about eventlet. We can make sure that PyMI uses the unpatched threading module, also ensuring that the blocking calls are run in a different thread, so that we don't block the calling thread, preventing other greenthreads from continuing theri execution. eventlet.tpool can be used to easily achieve this. |
PyMI subscribes to event providers, setting a callback that will be invoked when an event arrives. When called, the event watcher will block until an event is retrieved. A threading.Event is used internally by PyMI for the event waiting workflow.
The issue is that the threading module will be monkey patched by eventlet. The event callback is performed from a different thread, so attempting to set the event for which the event watcher waits will some times raise the "error: cannot switch to a different thread" greenlet exception, thus breaking the event listener.
This issue can be fixed at the os-win level, without having PyMI to know about eventlet. We can make sure that PyMI uses the unpatched threading module, also ensuring that the blocking calls are run in a different thread, so that we don't block the calling thread, preventing other greenthreads from continuing theri execution. eventlet.tpool can be used to easily achieve this.
Trace: http://paste.openstack.org/show/494805/ |
|