diff options
author | Armin Rigo <armin.rigo@gmail.com> | 2020-03-03 01:37:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 01:37:25 (GMT) |
commit | 6daa37fd42c5d5300172728e8b4de74fe0b319fc (patch) | |
tree | fea0f80ed7f996670197dc3b60896b306b29dc9b /Lib/test/test_import | |
parent | ce3a4984089b8e0ce5422ca32d75ad057b008074 (diff) | |
download | cpython-6daa37fd42c5d5300172728e8b4de74fe0b319fc.zip cpython-6daa37fd42c5d5300172728e8b4de74fe0b319fc.tar.gz cpython-6daa37fd42c5d5300172728e8b4de74fe0b319fc.tar.bz2 |
bpo-38091: Import deadlock detection causes deadlock (GH-17518)
Automerge-Triggered-By: @brettcannon
Diffstat (limited to 'Lib/test/test_import')
-rw-r--r-- | Lib/test/test_import/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py index 482fe6a..d50befc 100644 --- a/Lib/test/test_import/__init__.py +++ b/Lib/test/test_import/__init__.py @@ -436,16 +436,24 @@ class ImportTests(unittest.TestCase): os.does_not_exist def test_concurrency(self): + # bpo 38091: this is a hack to slow down the code that calls + # has_deadlock(); the logic was itself sometimes deadlocking. + def delay_has_deadlock(frame, event, arg): + if event == 'call' and frame.f_code.co_name == 'has_deadlock': + time.sleep(0.1) + 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() |