I'm using an async library (asyncpg) and I want to debug some async calls to query the database.
I place a pdb breakpoint and want try out a few queries:
(pdb) await asyncpg.fetch("select * from foo;")
*** SyntaxError: 'await' outside function
It would be great to be able to do this because it would allow me to try out a few SQL queries and see the result, all from the comfort of my debugger.
Is it possible?
asyncio.run(asyncpg.fetch("select * from foo;"))
work? – Illustrativeawait
to work, PDB would need to modify execution of a running generator (which is how coroutines are implemented internally) to provide a new yield (await) point. It's comparable to how, given a breakpoint inside a generator, you cannot runyield bla
from the PDB prompt. – Shrill