summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@enovance.com>2015-03-06 22:16:20 +0100
committerVictor Stinner <victor.stinner@enovance.com>2015-03-06 22:58:44 +0100
commit7c65b58195bf44c8d890414d724a563d19d325a9 (patch)
tree73509e3d7c1dd291d22ab90b9497f72e1e0dd14c
parenta306eae52f8cc84aa6219a6ada0baf8e4ea6c54e (diff)
downloadeventlet-semaphore_timeout.tar.gz
Disable the thread state locksemaphore_timeout
-rw-r--r--eventlet/green/thread.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/eventlet/green/thread.py b/eventlet/green/thread.py
index 2360310..f92c416 100644
--- a/eventlet/green/thread.py
+++ b/eventlet/green/thread.py
@@ -3,6 +3,7 @@ from eventlet.support.six.moves import _thread as __thread
from eventlet.support import greenlets as greenlet, six
from eventlet import greenthread
from eventlet.semaphore import Semaphore as LockType
+import sys
__patched__ = ['get_ident', 'start_new_thread', 'start_new', 'allocate_lock',
@@ -43,6 +44,19 @@ def __thread_body(func, args, kwargs):
def start_new_thread(function, args=(), kwargs=None):
+ if (sys.version_info >= (3, 4)
+ and getattr(function, '__module__', '') == 'threading'
+ and hasattr(function, '__self__')):
+ # Since Python 3.4, threading.Thread uses an internal lock
+ # automatically released when the python thread state is deleted.
+ # With monkey patching, eventlet uses green threads without python
+ # thread state, so the lock is not automatically released.
+ #
+ # Disable the thread state lock to avoid dead locks.
+ thread = function.__self__
+ thread._set_tstate_lock = lambda: None
+ thread._wait_for_tstate_lock = lambda *args, **kw: None
+
kwargs = kwargs or {}
g = greenthread.spawn_n(__thread_body, function, args, kwargs)
return get_ident(g)