title: How to build a python asyncio base coroutine?
body: <p>Its easy to create a coroutine that calls some other coroutine, but if for example i want to create a coroutine that doesn't block, how do I do that? Should I launch a thread that does that calculation and then capture the callback somehow?</p>
  
  <p>Looking at the asyncio.sleep implementation they do that calling the loop to return later on time instead of a "real" sleep</p>
  
  <p>I have come to this but its still not working.</p>
  
  <pre class="lang-py prettyprint-override"><code>import asyncio
  import concurrent.futures
  
  
  def inner_task(num_1, num_2):
      return num_1 ** num_2
  
  
  async def exp_coroutine(num_1, num_2):
  
      executor = concurrent.futures.ProcessPoolExecutor()
      return await loop.run_in_executor(executor, inner_task, num_1, num_2)
  
  
  async def my_base_coroutine(num_1, num_2):
      results = await exp_coroutine(num_1, num_2)
      print(results)
      return results
  
  
  loop = asyncio.get_event_loop()
  loop.create_task(my_base_coroutine(23, 876))
  loop.create_task(my_base_coroutine(23, 1))
  loop.create_task(my_base_coroutine(23, 35))
  
  tasks = asyncio.Task.all_tasks()
  loop.run_until_complete(asyncio.gather(*tasks))
  </code></pre>
  
  <p>Currently I am getting the results exactly how they are asked from and would expect the easier calculations first.</p>