Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test.
  • Loading branch information
ZeroIntensity committed Nov 19, 2024
commit b2feff877a6cdf9ffceb36199cab0d0f9a3a5bde
27 changes: 27 additions & 0 deletions Lib/test/test_interpreters/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ def run():
with threading_helper.start_threads(threads):
pass

def test_many_threads_running_and_destroying(self):
interp = interpreters.create()

def run():
try:
interp.exec("1")
interp.close()
except Exception as e:
# Ignore all interpreter errors, we just want to make
# sure that it doesn't crash
self.assertIsInstance(
e,
(
interpreters.ExecutionFailed,
interpreters.InterpreterNotFoundError,
interpreters.InterpreterError
)
)

threads = (threading.Thread(target=run) for _ in range(200))
with threading_helper.catch_threading_exception() as cm:
with threading_helper.start_threads(threads):
pass

self.assertIsNone(cm.exc_value)



if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
Expand Down