2
Vote

Debugging is broken by gevent monkey-patching

description

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.

comments

Zooba wrote Jul 16, 2012 at 3: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 visualstudio_py_launcher.py (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 http://pytools.codeplex.com/workitem/536, 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.