FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-152391: Improve `test_interpreters.test_stress` test by sobolevn · Pull Request #152396 · python/cpython · GitHub

Repository navigation

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Next Next commit
gh-152391: Improve test_interpreters.test_stress test
  • Loading branch information
sobolevn committed Jun 27, 2026
commit 449a7aa803c4cc076f1c00414dda7a3ae7e4e975
12 changes: 8 additions & 4 deletions Lib/test/test_interpreters/test_stress.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from test import support
from test.support import import_helper
from test.support import threading_helper
# Raise SkipTest if subinterpreters not supported.
_interpreters = import_helper.import_module('_interpreters')
from concurrent import interpreters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This doesn’t work, this imports _interpreters, the above was a skip.

stan@stanlaptop:~/dev/cpython{issue-152391}$ rm Modules/_interpreters.cpython-316d-x86_64-linux-gnu.so 
stan@stanlaptop:~/dev/cpython{issue-152391}$ ./python -c "import _interpreters"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import _interpreters
ModuleNotFoundError: Standard library module '_interpreters' was not found
stan@stanlaptop:~/dev/cpython{issue-152391}$ ./python -m test test_interpreters
Using random seed: 134531407
0:00:00 load avg: 0.87 mem: 50.5 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 0.87 mem: 50.5 MiB [1/1] test_interpreters
Failed to import test module: test.test_interpreters.test_channels
Traceback (most recent call last):
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 433, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 374, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "/home/stan/dev/cpython/Lib/test/test_interpreters/test_channels.py", line 11, in <module>
    from concurrent import interpreters
  File "/home/stan/dev/cpython/Lib/concurrent/interpreters/__init__.py", line 5, in <module>
    import _interpreters
ModuleNotFoundError: Standard library module '_interpreters' was not found

Failed to import test module: test.test_interpreters.test_queues
Traceback (most recent call last):
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 433, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 374, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "/home/stan/dev/cpython/Lib/test/test_interpreters/test_queues.py", line 10, in <module>
    from concurrent import interpreters
  File "/home/stan/dev/cpython/Lib/concurrent/interpreters/__init__.py", line 5, in <module>
    import _interpreters
ModuleNotFoundError: Standard library module '_interpreters' was not found

Failed to import test module: test.test_interpreters.test_stress
Traceback (most recent call last):
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 433, in _find_test_path
    module = self._get_module_from_name(name)
  File "/home/stan/dev/cpython/Lib/unittest/loader.py", line 374, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "/home/stan/dev/cpython/Lib/test/test_interpreters/test_stress.py", line 7, in <module>
    from concurrent import interpreters
  File "/home/stan/dev/cpython/Lib/concurrent/interpreters/__init__.py", line 5, in <module>
    import _interpreters
ModuleNotFoundError: Standard library module '_interpreters' was not found

test test_interpreters crashed -- Traceback (most recent call last):
  File "/home/stan/dev/cpython/Lib/test/libregrtest/single.py", line 210, in _runtest_env_changed_exc
    _load_run_test(result, runtests)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/stan/dev/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stan/dev/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File "/home/stan/dev/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File "/home/stan/dev/cpython/Lib/test/libregrtest/single.py", line 38, in run_unittest
    raise Exception("errors while loading tests")
Exception: errors while loading tests

0:00:00 load avg: 0.87 mem: 52.5 MiB [1/1/1] test_interpreters failed (uncaught exception)

== Tests result: FAILURE ==

1 test failed:
    test_interpreters

Total duration: 506 ms
Total tests: run=0
Total test files: run=1/1 failed=1
Result: FAILURE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

yeap :(
had to revert this.

from concurrent.interpreters import InterpreterError
from .utils import TestBase
Expand All @@ -25,6 +23,7 @@ def test_create_many_sequential(self):
del alive
support.gc_collect()

@threading_helper.requires_working_threading()
@support.bigmemtest(size=200, memuse=32*2**20, dry_run=False)
def test_create_many_threaded(self, size):
alive = []
Expand All @@ -44,6 +43,7 @@ def task():
@threading_helper.requires_working_threading()
@support.bigmemtest(size=200, memuse=34*2**20, dry_run=False)
def test_many_threads_running_interp_in_other_interp(self, size):
import_helper.import_module('_interpreters')
start = threading.Event()
interp = interpreters.create()

Expand Down Expand Up @@ -78,11 +78,15 @@ def run():
@support.nomemtest
def test_create_interpreter_no_memory(self):
import _testcapi
_interpreters = import_helper.import_module('_interpreters')

assertion = self.assertRaises(InterpreterError)
_testcapi.set_nomemory(0, 1)
Comment thread
sobolevn marked this conversation as resolved.
Resolved
with assertion:
_interpreters.create()
try:
with assertion:
_interpreters.create()
finally:
_testcapi.remove_mem_hooks()


if __name__ == '__main__':
Expand Down
Loading

Back | FazBrowse Home | New Git URL