If the event loop is already running, then Tornado's IOLoop.run_sync() won't work either (it may appear to work because we don't do enough checking for improper combinations of run_sync() and start(), but it's not safe).
Instead, you should do something like `debug().add_done_callback(lambda f: pdb.set_trace())` and then `continue` (I'm not a pdb user so I'm not sure of the exact commands), so pdb will let the outer event loop run and then break back in once the given coroutine is finished. -Ben On Tue, Dec 8, 2015 at 1:45 AM, Al Johri <[email protected]> wrote: > Hi, > > Similar to how Tornado has a IOLoop.current().run_sync method, is there > anyway that while I'm in pdb I can schedule a coroutine or future, have it > execute immediately, and block until it finishes? > > For example, if I'm writing to a database and I need to test something, > I'd like to be able to type within pdb "await db.insert(mydocument)" for > testing purposes and have it execute immediately. > > Just curious if this is even within the realm of possibility; I'm rather > new to asyncio so I apologize if this has been discussed before or is > completely preposterous. > > I've tried to do things like, write a coroutine called "debug" such as: > > async def debug(): > await db.insert(mydocument) > > and then within pdb do something along the lines of > > loop.run_until_complete(debug()) > > but obviously this can't be done as the loop is already running. > > Would love any insight on how to achieve this. Thanks! > > Al >
