Interrupt (pause) running Python program in pdb?

No, python2’s pdb doesn’t support this, but you add this code to your program as a workaround: def debug_signal_handler(signal, frame): import pdb pdb.set_trace() import signal signal.signal(signal.SIGINT, debug_signal_handler) Related questions: Showing the stack trace from a running Python application enter pdb with kill signal

How to debug python CLI that takes stdin?

Another option is to create you own Pdb object, and set there the stdin and stdout. My proof of concept involves 2 terminals, but for sure some work can be merged some kind of very unsecure network server. Create two fifos: mkfifo fifo_stdin mkfifo fifo_stdout In one terminal, open stdout on background, and write to … Read more

How to await a coroutine in pdb

I had a similar problem debugging the useage of aiofile. I then found a solution using nest_asyncio. For example if one has the following async example script: import asyncio from aiofile import async_open import nest_asyncio async def main(): async with async_open(“/tmp/hello.txt”, ‘w+’) as afp: await afp.write(“Hello “) await afp.write(“world”) afp.seek(0) breakpoint() print(await afp.read()) if __name__==”__main__”: … Read more

How to debug a Python module run with python -m from the command line?

You can’t do it now, because -m terminates option list python -h … -m mod : run library module as a script (terminates option list) … That means it’s mod’s job to interpret the rest of the arguments list and this behavior fully depends on how mod is designed internally and whether it support another … Read more

In the Python debugger pdb, how do you exit interactive mode without terminating the debugging session

Sending an EOF by pressing Ctrl + D should work: $ python -m pdb myscript.py > …/myscript.py(1)<module>() -> import os (Pdb) import code (Pdb) code.interact() Python 2.7.11 (default, Dec 27 2015, 01:48:39) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin Type “help”, “copyright”, “credits” or “license” for more information. (InteractiveConsole) >>> <CTRL-D> (Pdb) c … Read more

tech