diff options
| author | Victor Stinner <victor.stinner@enovance.com> | 2015-03-06 22:16:20 +0100 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2015-04-05 03:32:57 +0300 |
| commit | 390e71d89883649dd55fbb70dc8686bf99e2a2e2 (patch) | |
| tree | 79cbc060dc1986688c7d030cadaf51a3a85cac3c | |
| parent | b5bfe1cad90788e6635d00565b1f5f98c3ecd2c5 (diff) | |
| download | eventlet-pr/187.tar.gz | |
Disable the thread state lockpr/187
| -rw-r--r-- | eventlet/green/thread.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/eventlet/green/thread.py b/eventlet/green/thread.py index 2360310..7bd24d4 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) |
