title: How can I wrap a synchronous function in an async coroutine?
body: <p>I'm using <a href="https://github.com/aio-libs/aiohttp" rel="noreferrer">aiohttp</a> to build an API server that sends TCP requests off to a seperate server. The module that sends the TCP requests is synchronous and a black box for my purposes. So my problem is that these requests are blocking the entire API. I need a way to wrap the module requests in an asynchronous coroutine that won't block the rest of the API.</p>
  
  <p>So, just using <code>sleep</code> as a simple example, is there any way to somehow wrap time-consuming synchronous code in a non-blocking coroutine, something like this:</p>
  
  <pre><code>async def sleep_async(delay):
      # After calling sleep, loop should be released until sleep is done
      yield sleep(delay)
      return 'I slept asynchronously'
  </code></pre>