Skip to content

Commit

Permalink
pythongh-98360: multiprocessing now spawns children on Windows with c…
Browse files Browse the repository at this point in the history
…orrect argv[0] in virtual environments
  • Loading branch information
zooba committed Oct 19, 2022
1 parent 52fcba6 commit 42aa3cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Lib/test/_test_venv_multiprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import multiprocessing
import random
import sys
import time

def fill_queue(queue, code):
queue.put(code)


def drain_queue(queue, code):
if code != queue.get():
sys.exit(1)


def test_func():
code = random.randrange(0, 1000)
queue = multiprocessing.Queue()
fill_pool = multiprocessing.Process(
target=fill_queue,
args=(queue, code)
)
drain_pool = multiprocessing.Process(
target=drain_queue,
args=(queue, code)
)
drain_pool.start()
fill_pool.start()
fill_pool.join()
drain_pool.join()


def main():
test_pool = multiprocessing.Process(target=test_func)
test_pool.start()
test_pool.join()
sys.exit(test_pool.exitcode)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixes :mod:`multiprocessing` spawning child processes on Windows from a
virtual environment to ensure that child processes that also use
:mod:`multiprocessing` to spawn more children will recognize that they are
in a virtual environment.

0 comments on commit 42aa3cc

Please sign in to comment.