Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't crash on PyPy 7.0.0 #547

Merged
merged 2 commits into from Oct 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions eventlet/patcher.py
Expand Up @@ -353,17 +353,26 @@ def _green_existing_locks():
import eventlet.green.thread
lock_type = type(threading.Lock())
rlock_type = type(threading.RLock())
if sys.version_info[0] >= 3:
if hasattr(threading, '_PyRLock'):
# this happens on CPython3 and PyPy >= 7.0.0: "py3-style" rlocks, they
# are implemented natively in C and RPython respectively
py3_style = True
pyrlock_type = type(threading._PyRLock())
else:
# this happens on CPython2.7 and PyPy < 7.0.0: "py2-style" rlocks,
# they are implemented in pure-python
py3_style = False
pyrlock_type = None

# We're monkey-patching so there can't be any greenlets yet, ergo our thread
# ID is the only valid owner possible.
tid = eventlet.green.thread.get_ident()
for obj in gc.get_objects():
if isinstance(obj, rlock_type):
if (sys.version_info[0] == 2 and
if (not py3_style and
isinstance(obj._RLock__block, lock_type)):
temoto marked this conversation as resolved.
Show resolved Hide resolved
_fix_py2_rlock(obj, tid)
elif (sys.version_info[0] >= 3 and
elif (py3_style and
not isinstance(obj, pyrlock_type)):
temoto marked this conversation as resolved.
Show resolved Hide resolved
_fix_py3_rlock(obj)

Expand Down