mirror of
https://github.com/python/cpython.git
synced 2026-01-28 13:45:18 +00:00
gh-126631: gh-137996: fix pre-loading of `__main__` The `main_path` parameter was renamed `init_main_from_name`, update the forkserver code accordingly. This was leading to slower startup times when people were trying to preload the main module. --------- (cherry picked from commit 0912b3a6dbd226bea79eb8d70d5a06230804d4cb) Co-authored-by: Duane Griffin <duaneg@dghda.com>
15 lines
287 B
Python
15 lines
287 B
Python
import multiprocessing
|
|
|
|
print(f"{__name__}")
|
|
|
|
def f():
|
|
print("f")
|
|
|
|
if __name__ == "__main__":
|
|
ctx = multiprocessing.get_context("forkserver")
|
|
ctx.set_forkserver_preload(['__main__'])
|
|
for _ in range(2):
|
|
p = ctx.Process(target=f)
|
|
p.start()
|
|
p.join()
|