cpython/Lib/test/_test_venv_multiprocessing.py
Miss Islington (bot) 4e0fda59f1
gh-98360: multiprocessing now spawns children on Windows with correct argv[0] in virtual environments (GH-98462)
(cherry picked from commit e48f9b2b7e)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-10-22 20:10:11 +01:00

40 lines
762 B
Python

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()