-
Notifications
You must be signed in to change notification settings - Fork 44
Fix #170: Use a private gevent threadpool #171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
tango/gevent_executor.py
Outdated
try: | ||
return _THREAD_POOL | ||
except NameError: | ||
_THREAD_POOL = ThreadPool(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this limit of 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you are right. I will make it unlimited
tango/gevent_executor.py
Outdated
fn = wrap_errors(fn) | ||
result = super(ThreadPool, self).spawn(fn, *args, **kwargs) | ||
result._get = result.get | ||
result.get = types.MethodType(get_with_exception, result, type(result)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type(result)
argument needs to be removed, it's not compatible with python 3 (and it's not mandatory with python 2)
tango/gevent_executor.py
Outdated
global _THREAD_POOL | ||
try: | ||
return _THREAD_POOL | ||
except NameError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use if _THREAD_POOL is None:
just like in get_global_executor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
FYI, on gevent/gevent#55 they propose to configure this behaviour at the application level. If, for example, you want to suppress greenlet exception printing you can configure what gevent considers to be an error by doing something like this: import gevent.hub
gevent.hub.Hub.NOT_ERROR=(Exception,) For, PyTango, the fact that we ask the tango method to be executed in a gevent threadpool is an implementation detail so the approach to wrap tango call errors is the correct one. Another info is that the code to wrap exceptions exists in gevent itself |
Use a private ThreadPool (previous implementation was patching default gevent threadpool which might prevent other libraries using the same threadpool from working properly together with PyTango)
@tiagocoutinho Thanks! |
…ls#171) * Fix tango-controls#170: prevent gevent from calling sys.excepthook Use a private ThreadPool (previous implementation was patching default gevent threadpool which might prevent other libraries using the same threadpool from working properly together with PyTango)
Use a private ThreadPool (previous implementation was
patching default gevent threadpool which might prevent
other libraries using the same threadpool from working
properly together with PyTango)