Todo: 集成多平台 解决因SaiNiu线程抢占资源问题 本地提交测试环境打包 和 正式打包脚本与正式环境打包bat 提交Python32环境包 改进多日志文件生成情况修改打包日志细节
This commit is contained in:
40
Utils/PythonNew32/Lib/test/_test_venv_multiprocessing.py
Normal file
40
Utils/PythonNew32/Lib/test/_test_venv_multiprocessing.py
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