Skip to content

Instantly share code, notes, and snippets.

@azinman
Created October 5, 2016 21:41
Show Gist options
  • Save azinman/f201d97a1d4bf9e8496d66b0ee505cfe to your computer and use it in GitHub Desktop.
Save azinman/f201d97a1d4bf9e8496d66b0ee505cfe to your computer and use it in GitHub Desktop.
Enable PTVSD remote debugging despite gevent monkey patching
# Somewhere in our Django stack gevent was being invoked and monkey patching socket and threads.
# PTVSD uses low-level sockets + a thread to work, and the monkey patched version (even if you
# call gevent.monkey.patch_all()) somehow was not working correctly.
# By reloading those modules, you can get the debugger to work correct and step through your code.
import ptvsd, socket, thread, threading
reload(socket)
reload(thread)
reload(threading)
ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
ptvsd.wait_for_attach()
ptvsd.break_into_debugger()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment