多处理调试技术 [英] Multiprocessing debug techniques

查看:54
本文介绍了多处理调试技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调试多进程应用程序时遇到麻烦(特别是在python的多处理模块中使用进程池).我有一个明显的死锁,我不知道是什么原因造成的.堆栈跟踪信息不足以描述问题,因为它仅在多处理模块中显示代码.

I'm having trouble debugging a multi-process application (specifically using a process pool in python's multiprocessing module). I have an apparent deadlock and I do not know what is causing it. The stack trace is not sufficient to describe the issue, as it only displays code in the multiprocessing module.

是否有用于调试死锁的任何python工具或其他常规技术?

Are there any python tools, or otherwise general techniques used to debug deadlocks?

推荐答案

是的,调试死锁很有趣.您可以将日志记录级别设置为更高-有关以下内容的说明,请参见 Python文档它,但是很快:

Yah, debugging deadlocks is fun. You can set the logging level to be higher -- see the Python documentation for a description of it, but really quickly:

import multiprocessing, logging
logger = multiprocessing.log_to_stderr()
logger.setLevel(multiprocessing.SUBDEBUG)

此外,在代码中处理资源的任何内容或可能引起争用的内容添加日志记录.最终,陷入黑暗:在导入过程中产生子进程可能会导致问题.

Also, add logging for anything in your code that deals with a resource or whatnot that might be in contention. Finally, shot in the dark: spawning off child processes during an import might cause a problem.

这篇关于多处理调试技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆