mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-135335: Simplify preload regression test using __main__ (GH-138686)
Simplify preload regression test using `__main__` With the fix for gh-126631 `__main__` modules can be preloaded and the regression test for gh-135335 can be simplified to just use a self-contained script rather than requiring a module. Note this assumes and implicitly tests that `__main__` is preloaded by default.
This commit is contained in:
parent
23b67aa037
commit
425f24e4fa
2 changed files with 5 additions and 24 deletions
|
|
@ -1,15 +1,11 @@
|
|||
import multiprocessing
|
||||
import sys
|
||||
|
||||
modname = 'preloaded_module'
|
||||
print(__name__, end='', file=sys.stderr)
|
||||
print(__name__, end='', file=sys.stdout)
|
||||
if __name__ == '__main__':
|
||||
if modname in sys.modules:
|
||||
raise AssertionError(f'{modname!r} is not in sys.modules')
|
||||
multiprocessing.set_start_method('forkserver')
|
||||
multiprocessing.set_forkserver_preload([modname])
|
||||
for _ in range(2):
|
||||
p = multiprocessing.Process()
|
||||
p.start()
|
||||
p.join()
|
||||
elif modname not in sys.modules:
|
||||
raise AssertionError(f'{modname!r} is not in sys.modules')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue