Error when profiling an otherwise perfectly working multiprocessing python script with cProfile

有些话、适合烂在心里 提交于 2019-12-04 05:05:23
user8283559

It seems cProfile simply doesn't work with multiprocessing.

If you are happy to modify the code only profile the main process (or add specific profiling for the subprocesses), cProfile.run() seems to work to a degree.

In your example, replace

exit(main())

with

exit(cProfile.run('main()')

That at least works if the parallel function is a global scope function, not sure that is also true for a class like in your case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!