title: How to run a coroutine and wait it result from a sync func when the loop is running?
body: <p>I have a code like the foolowing:</p>
  
  <pre><code>def render():
      loop = asyncio.get_event_loop()
  
      async def test():
          await asyncio.sleep(2)
          print("hi")
          return 200
  
      if loop.is_running():
          result = asyncio.ensure_future(test())
      else:
          result = loop.run_until_complete(test())
  </code></pre>
  
  <p>When the <code>loop</code> is not running is quite easy, just use <code>loop.run_until_complete</code> and it return the coro result but if the loop is already running (my blocking code running in app which is already running the loop) I cannot use <code>loop.run_until_complete</code> since it will raise an exception; when I call <code>asyncio.ensure_future</code> the task gets scheduled and run, but I want to wait there for the result, does anybody knows how to do this? Docs are not very clear how to do this.</p>
  
  <p>I tried passing a <code>concurrent.futures.Future</code> calling <code>set_result</code> inside the coro and then calling <code>Future.result()</code> on my blocking code, but it doesn't work, it blocks there and do not let anything else to run. ANy help would be appreciated.</p>