mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-07-28 05:58:28 -06:00
Removed the Requirement to Install Python and NodeJS (Now Bundled with Borealis)
This commit is contained in:
40
Dependencies/Python/Lib/test/_test_venv_multiprocessing.py
vendored
Normal file
40
Dependencies/Python/Lib/test/_test_venv_multiprocessing.py
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
import multiprocessing
|
||||
import random
|
||||
import sys
|
||||
|
||||
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():
|
||||
multiprocessing.set_start_method('spawn')
|
||||
test_pool = multiprocessing.Process(target=test_func)
|
||||
test_pool.start()
|
||||
test_pool.join()
|
||||
sys.exit(test_pool.exitcode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user