title: python asyncio add_done_callback with async def
body: <p>I have 2 functions: The first one, <code>def_a</code>, is an asynchronous function and the second one is <code>def_b</code> which is a regular function and called with the result of <code>def_a</code> as a callback with the <code>add_done_callback</code> function.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>import asyncio
  
  def def_b(result):
      next_number = result.result()
      # some work on the next_number
      print(next_number + 1)
  
  async def def_a(number):
      await some_async_work(number)
      return number + 1
  
  loop = asyncio.get_event_loop()
  task = asyncio.ensure_future(def_a(1))
  task.add_done_callback(def_b)
  response = loop.run_until_complete(task)
  loop.close()
  </code></pre>
  
  <p>And it's work perfectly.</p>
  
  <p>The problem began when also the second function, <code>def_b</code>, became asynchronous. Now it looks like this:</p>
  
  <pre><code>async def def_b(result):
      next_number = result.result()
      # some asynchronous work on the next_number
      print(next_number + 1)
  </code></pre>
  
  <p>But now I can not provide it to the <code>add_done_callback</code> function, because it's not a regular function.</p>
  
  <p>My question is- Is it possible and how can I provide <code>def_b</code> to the <code>add_done_callback</code> function if <code>def_b</code> is asynchronous?</p>