8000 gh-109700: Improve stress tests for interpreter creation by serhiy-storchaka · Pull Request #109946 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109700: Improve stress tests for interpreter creation #109946

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

Merged
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.
8000 Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add guards also for other stress tests.
  • Loading branch information
serhiy-storchaka committed May 4, 2025
commit 5dd48d6aa1de25905ad43e13001aa72f596aa3ee
22 changes: 15 additions & 7 deletions Lib/test/test_interpreters/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ class StressTests(TestBase):
# but not so many that any test takes too long.

@support.requires_resource('cpu')
def test_create_many_sequential(self):
@support.bigmemtest(size=100, memuse=6.2*2**20, dry_run=False)
def test_create_many_sequential(self, size):
alive = []
for _ in range(100):
for _ in range(size):
interp = interpreters.create()
alive.append(interp)
del alive
support.gc_collect()

@support.requires_resource('cpu')
@support.bigmemtest(size=6.39*2**30, memuse=1, dry_run=False)
@support.bigmemtest(size=200, memuse=32*2**20, dry_run=False)
def test_create_many_threaded(self, size):
alive = []
start = threading.Event()
Expand All @@ -33,15 +36,17 @@ def task():
raise TimeoutError
interp = interpreters.create()
alive.append(interp)
threads = [threading.Thread(target=task) for _ in range(200)]
threads = [threading.Thread(target=task) for _ in range(size)]
with threading_helper.start_threads(threads):
start.set()
del alive
support.gc_collect()

@support.requires_resource('cpu')
@threading_helper.requires_working_threading()
def test_many_threads_running_interp_in_other_interp(self):
@support.bigmemtest(size=200, memuse=32*2**20, dry_run=False)
def test_many_threads_running_interp_in_other_interp(self, size):
start = threading.Event()
interp = interpreters.create()

script = f"""if True:
Expand All @@ -50,6 +55,9 @@ def test_many_threads_running_interp_in_other_interp(self):
"""

def run():
# try to create all interpreters simultaneously
if not start.wait(10):
raise TimeoutError
interp = interpreters.create()
alreadyrunning = (f'{interpreters.InterpreterError}: '
'interpreter already running')
Expand All @@ -64,9 +72,9 @@ def run():
else:
success = True

threads = (threading.Thread(target=run) for _ in range(200))
threads = [threading.Thread(target=run) for _ in range(size)]
with threading_helper.start_threads(threads):
pass
start.set()


if __name__ == '__main__':
Expand Down
Loading
0