Pydevd's effect on python's multiprocessing & threading

Answered

What is the effect of pydevd.py's -- pydev's debugger used by Eclipsed and Pycahrm -- effect on python's multiprocessing & threading?

When I start my python server -- which uses both multiprocessing & threading -- without debugging, it crashes on startup with no helpful traceback. However, when I run with Pycharm's debugger, the process starts up and functions properly.

So what would be causing this difference in performance? Could it be serialization of Process() or imposing of some orders on Thread()?

3 comments
Comment actions Permalink

Hi, pydevd patches both multiprocessing and threading indeed, see https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/pydev_monkey.py for details. Could you share a sample code which works with Run but fails under the debugger?

0
Comment actions Permalink

Thanks for your help!

I am afraid I can't because it is my company's server code I am developing.

 

Could you help me out navigate the code you have linked? Any details on which part of the code or which function does the "patching" would help.

Also, what is the change of behavior before vs after "patching"?

 

Thanks again :)

0
Comment actions Permalink

Hi Isaaclee! In fact, almost every function in this module does some patching. For example, we patch new process creation: https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/_pydev_bundle/pydev_monkey.py#L606 and new threads creation: https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/_pydev_bundle/pydev_monkey.py#L781
Do you use `gevent` or any libraries which patch builtin modules? We do some tricks to save copy of non-patched libraries: https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py#L136
Do you use PyQt? If yes, we patch some pyqt modules as well: https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py#L13
Also we start our util threads for communicating with IDE and it can affect program behaviour as well: https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/pydevd.py#L104

 

0

Please sign in to leave a comment.