Multiprocessing debug techniques

前端 未结 2 1805
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 04:54

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

2条回答
  •  走了就别回头了
    2021-02-01 05:32

    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.

提交回复
热议问题