Commit 6bc64ff4 authored by Jason Madden's avatar Jason Madden

correct attribute name under py3

parent 8f5252cd
...@@ -163,15 +163,20 @@ def _patch_existing_locks(threading): ...@@ -163,15 +163,20 @@ def _patch_existing_locks(threading):
# locked objects...at least if they use `with`. To be sure, we look at every object # locked objects...at least if they use `with`. To be sure, we look at every object
# Since we're supposed to be done very early in the process, there shouldn't be # Since we're supposed to be done very early in the process, there shouldn't be
# too many. # too many.
# By definition there's only one thread running, so the various
# owner attributes were the old (native) thread id. Make it our
# current greenlet id so that when it wants to unlock and compare
# self.__owner with _get_ident(), they match.
gc = __import__('gc') gc = __import__('gc')
for o in gc.get_objects(): for o in gc.get_objects():
if isinstance(o, rlock_type): if isinstance(o, rlock_type):
if o._RLock__owner is not None: if hasattr(o, '_owner'): # Py3
# By definition there's only one thread running, if o._owner is not None:
# so this was the old (native) thread id. Make o._owner = tid
# it our current greenlet id so that when it wants to unlock else:
# and compare self.__owner with _get_ident(), they match if o._RLock__owner is not None:
o._RLock__owner = tid o._RLock__owner = tid
elif isinstance(o, _ModuleLock): elif isinstance(o, _ModuleLock):
if o.owner is not None: if o.owner is not None:
o.owner = tid o.owner = tid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment