Debugging your Lager Python program

When using lager python, a remote pdb tunnel is automatically established. To use it, add a call to breakpoint() in your code, and then use telnet to connect to port 5555 on host 127.0.0.1.

Simple pdb example

breakpoint.py
def foo():
   print("hello")

def bar():
   print("world")

def main():
   print("started...")
   breakpoint()
   foo()
   bar()

if __name__ == '__main__':
   main()

Save the above listing as breakpoint.py

➜  lager python breakpoint.py
started...
RemotePdb session open at 0.0.0.0:5555, waiting for connection ...
RemotePdb session open at 0.0.0.0:5555, waiting for connection ...

Then in a separate terminal window:

➜  telnet 127.0.0.1 5555
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
> /tmp/tmpw5kcntdp.py(10)main()
-> foo()