This project has moved and is read-only. For the latest updates, please go here.

Debugging is broken by gevent monkey-patching


Gevent uses monkey patching for making IO function cooperative, and work with greenlets:

from gevent import monkey; monkey.patch_all()

After the monkey patching is done, debugging no longer works. I would be good to be able to debug monkey patched applications.


Zooba wrote Jul 16, 2012 at 4:32 PM

It looks like this is because we monkey patch the thread package as well. We pass the call through to the original value, but gevent doesn't, so using monkey.patch_all() before the debugger should work.

At the moment this can only be done by modifying (in wherever PTVS is installed) to include the gevent import and patch - you can try this yourself and see if it works. It looks like gevent won't repatch the package, so you can leave the call in your script as well.

Longer term, the best solution to this sort of issue may be, which will let you manually connect to our debugger as part of the script. That way, any dependencies such as this can easily be imported before our debugger is.

Nanalich wrote Jun 12, 2013 at 7:25 AM

Adding "from gevent import monkey; monkey.patch_all()" before "import visualstudio_py_debugger" doesn't work.

It seems the problem occurs no matter gevent monkey patches before or after the debugger.

Zooba wrote Jun 12, 2013 at 7:36 PM

That's a pity, I guess gevent is doing something that completely breaks us.

When we get a chance we'll take a closer look at this, but in the mean time you may have some luck using our remote debugging support (when run locally it's basically identical to regular debugging - we use a socket anyway - but it lets the script attach cooperatively) or mixed-mode debugging, which will be in our upcoming release.