Created
September 20, 2017 21:05
-
-
Save ionelmc/9989865957eb9377ca75a53c146bf116 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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