As reported at #715 (review)
Bad news: somewhere between 3.10.0b1 and 3.10.0rc1, test_patcher_existing_locks_locked started failing with RuntimeError: cannot release un-acquired lock around
I'm still scratching my head over that one. It looks like gc.get_referrers(old) is mostly returning lists and dicts, though? I wonder if it's somehow related to the trouble I was seeing with __builtins__ showing up as a dict in socket_test.test_error_is_timeout...
I decided to bisect the CPython for the commit which broke this test. I have found this commit python/cpython@e30fe27 . When running the test suite, it passes on its parent commit, but fails on this commit (the same way it fails for released 3.10.0). Just as information, it was between 3.10.0_beta2 and 3.10.0_beta3.
Now, about how to fix it? Sadly I'm quite new to eventlet and I don't understand quite well the code here:
|
lock_type = type(threading.Lock()) |
|
rlock_type = type(threading.RLock()) |
|
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 |
But when I tested the types on multiple targets (py3.8, py3.9, py3.10, pypy7.3.5, pypy7.3.6) it always returned
_thread.RLock for
type(threading.RLock()).
So just as a test, I tried to manually set
pyrlock_type = rlock_type at line 398, and the specific test passed. Here is the diff.
diff --git a/eventlet/patcher.py b/eventlet/patcher.py
index b249d6f..3f828a7 100644
--- a/eventlet/patcher.py
+++ b/eventlet/patcher.py
@@ -395,7 +395,7 @@ def _green_existing_locks():
# 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())
+ pyrlock_type = rlock_type
else:
# this happens on CPython2.7 and PyPy < 7.0.0: "py2-style" rlocks,
# they are implemented in pure-python
I will repeat that I have no idea if my change is even mildly correct. I just know it managed to make this test, and added no new regressions when all other tests were run. That is also the reason this isn't an Pull Request, and just an issue report.
My test environment is Gentoo, using master version of eventlet. Tested on CPython 3.8.12 and 3.9.7 (passes with and without the diff) and CPython 3.10.0 (needed the diff, but there were still other failures in other parts, even without the diff), and PyPy3-7.3.5 and PyPy3-7.3.6 (passes with and without the diff).
As reported at #715 (review)
I decided to bisect the CPython for the commit which broke this test. I have found this commit python/cpython@e30fe27 . When running the test suite, it passes on its parent commit, but fails on this commit (the same way it fails for released 3.10.0). Just as information, it was between 3.10.0_beta2 and 3.10.0_beta3.
Now, about how to fix it? Sadly I'm quite new to eventlet and I don't understand quite well the code here:
eventlet/eventlet/patcher.py
Lines 392 to 403 in 8904a33
But when I tested the types on multiple targets (py3.8, py3.9, py3.10, pypy7.3.5, pypy7.3.6) it always returned
_thread.RLockfortype(threading.RLock()).So just as a test, I tried to manually set
pyrlock_type = rlock_typeat line 398, and the specific test passed. Here is the diff.I will repeat that I have no idea if my change is even mildly correct. I just know it managed to make this test, and added no new regressions when all other tests were run. That is also the reason this isn't an Pull Request, and just an issue report.
My test environment is Gentoo, using
masterversion of eventlet. Tested on CPython 3.8.12 and 3.9.7 (passes with and without the diff) and CPython 3.10.0 (needed the diff, but there were still other failures in other parts, even without the diff), and PyPy3-7.3.5 and PyPy3-7.3.6 (passes with and without the diff).