8000 gh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments by zooba · Pull Request #98462 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments #98462

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-98360: multiprocessing now spawns children on Windows with correct…
… argv[0] in virtual environments
  • Loading branch information
zooba committed Oct 19, 2022
commit 42aa3cc2bc3c81aa0057dacfdd9a2d344dc7b3cb
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