-
Notifications
You must be signed in to change notification settings - Fork 333
Closed
Description
The threading.RLock class was reimplemented in C in Python 3.2. threading.RLock doesn't use _thread.get_ident() or threading.get_ident(), but it calls directly the C function. Because of that, RLock doesn't work ("as expected") with eventlet monkey-patching. Example:
#!python
import eventlet
eventlet.monkey_patch()
import threading
#threading.RLock = threading._PyRLock
def func(c):
with c:
print("thread: owned?", c._is_owned())
c.notify()
print("thread: owned?", c._is_owned())
c = threading.Condition()
print("LOCK", threading.RLock)
with c:
t = threading.Thread(target=func, args=(c,))
t.start()
print("main: owned?", c._is_owned())
c.wait()
print("main: owned?", c._is_owned())
The code hangs with eventlet 0.16 on Python 3.5 (and probably also Python 3.2, 3.3 and 3.4).
I tried to reuse the Python implementation of the RLock class (threading._PyRLock), but in this case c.notify() raises: RuntimeError("cannot notify on un-acquired lock").
I will work on a fix.
Note: I'm working on porting the Oslo Messaging project to Python 3. The initial issue came from a threading.Condition object, threading.Condition uses internally a threading.RLock.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels