Skip to content

Instantly share code, notes, and snippets.

View azinman's full-sized avatar

Aaron Zinman azinman

  • San Francisco
View GitHub Profile
@azinman
azinman / unmonkeypatch.py
Created October 5, 2016 21:41
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()