-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-98360: multiprocessing now spawns children on Windows with correct…
… argv[0] in virtual environments (GH-98462) (cherry picked from commit e48f9b2) Co-authored-by: Steve Dower <[email protected]>
- Loading branch information
1 parent
49d7993
commit ace6611
Showing
4 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Windows/2022-10-19-20-00-28.gh-issue-98360.O2m6YG.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |