[pypy-commit] pypy release-pypy3.6-v7.x: merge py3.6 into release
mattip
pypy.commits at gmail.com
Tue Dec 10 11:50:06 EST 2019
Author: Matti Picus <matti.picus at gmail.com>
Branch: release-pypy3.6-v7.x
Changeset: r98266:533398cfd64e
Date: 2019-12-10 18:46 +0200
http://bitbucket.org/pypy/pypy/changeset/533398cfd64e/
Log: merge py3.6 into release
diff --git a/lib-python/3/importlib/_bootstrap.py b/lib-python/3/importlib/_bootstrap.py
--- a/lib-python/3/importlib/_bootstrap.py
+++ b/lib-python/3/importlib/_bootstrap.py
@@ -67,6 +67,7 @@
# Deadlock avoidance for concurrent circular imports.
me = _thread.get_ident()
tid = self.owner
+ count = 0
while True:
lock = _blocking_on.get(tid)
if lock is None:
@@ -74,6 +75,14 @@
tid = lock.owner
if tid == me:
return True
+ # workaround for https://bugs.python.org/issue38091:
+ # instead of looping here forever, eventually return False.
+ # Unsure if this will cause real deadlocks to go undetected,
+ # but at least it doesn't cause *this* logic here to
+ # deadlock when there is otherwise no deadlock!
+ count += 1
+ if count >= 100:
+ return False
def acquire(self):
"""
diff --git a/lib-python/3/test/test_import/__init__.py b/lib-python/3/test/test_import/__init__.py
--- a/lib-python/3/test/test_import/__init__.py
+++ b/lib-python/3/test/test_import/__init__.py
@@ -366,16 +366,22 @@
os.does_not_exist
def test_concurrency(self):
+ def delay_has_deadlock(frame, event, arg):
+ if event == 'call' and frame.f_code.co_name == 'has_deadlock':
+ time.sleep(0.05)
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'data'))
try:
exc = None
def run():
+ sys.settrace(delay_has_deadlock)
event.wait()
try:
import package
except BaseException as e:
nonlocal exc
exc = e
+ sys.settrace(None)
for i in range(10):
event = threading.Event()
More information about the pypy-commit
mailing list