title: Await an async function in Python debugger
body: <p>Is it possible to <code>await</code> arbitrary calls to an <code>async</code> function when inside a Python debugger? </p>
  
  <p>Say I have the following code in some <code>main.py</code> file:</p>
  
  <pre class="lang-py prettyprint-override"><code>import asyncio
  
  async def bar(x):
      return x + 1
  
  async def foo():
      import ipdb; ipdb.set_trace()
  
  asyncio.run(foo())
  </code></pre>
  
  <p>Now I want to test calling <code>bar()</code> with some argument inside the debugger to test the results. The following happens:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ python3 main.py
  &gt; /Users/user/test/main.py(8)foo()
        7     import ipdb; ipdb.set_trace()
  ----&gt; 8     return None
        9
  
  ipdb&gt; bar(1)
  &lt;coroutine object bar at 0x10404ae60&gt;
  main.py:1: RuntimeWarning: coroutine 'bar' was never awaited
    import asyncio
  RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  ipdb&gt; await bar(1)
  *** SyntaxError: 'await' outside function
  </code></pre>
  
  <p>Of course, I can get around this by having <code>x = await bar(1)</code> above my <code>ipdb.set_trace()</code>, and then inspecting the results, but then I can't try calling my functions in real time while the debugger is active.</p>