Skip to content

Instantly share code, notes, and snippets.

@ionelmc ionelmc/debugger.py
Created Sep 20, 2017

Embed
What would you like to do?
"""
Make sure you have a `socat readline unix-listen:/tmp/debugger` or `socat - unix-listen:/tmp/debugger` running in
a termial before using set_trace.
"""
def set_trace():
from pdb import Pdb
import os
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect('/tmp/debugger')
fd = sock.detach()
pdb = Pdb(stdin=os.fdopen(fd, 'r'), stdout=os.fdopen(fd, 'w'))
pdb.set_trace()
if __name__ == "__main__":
set_trace()
for i in range(10):
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.