Skip to content

Commit 42aa3cc

Browse files
committed
pythongh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments
1 parent 52fcba6 commit 42aa3cc

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import multiprocessing
2+
import random
3+
import sys
4+
import time
5+
6+
def fill_queue(queue, code):
7+
queue.put(code)
8+
9+
10+
def drain_queue(queue, code):
11+
if code != queue.get():
12+
sys.exit(1)
13+
14+
15+
def test_func():
16+
code = random.randrange(0, 1000)
17+
queue = multiprocessing.Queue()
18+
fill_pool = multiprocessing.Process(
19+
target=fill_queue,
20+
args=(queue, code)
21+
)
22+
drain_pool = multiprocessing.Process(
23+
target=drain_queue,
24+
args=(queue, code)
25+
)
26+
drain_pool.start()
27+
fill_pool.start()
28+
fill_pool.join()
29+
drain_pool.join()
30+
31+
32+
def main():
33+
test_pool = multiprocessing.Process(target=test_func)
34+
test_pool.start()
35+
test_pool.join()
36+
sys.exit(test_pool.exitcode)
37+
38+
39+
if __name__ == "__main__":
40+
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fixes :mod:`multiprocessing` spawning child processes on Windows from a
2+
virtual environment to ensure that child processes that also use
3+
:mod:`multiprocessing` to spawn more children will recognize that they are
4+
in a virtual environment.

0 commit comments

Comments
 (0)