title: Wrapping synchronous requests into asyncio (async/await)?
body: <p>I am writing a tool in Python 3.6 that sends requests to several APIs (with various endpoints) and collects their responses to parse and save them in a database.</p>
  
  <p>The API clients that I use have a <strong>synchronous</strong> version of requesting a URL, for instance they use</p>
  
  <p><code>urllib.request.Request('...</code></p>
  
  <p>Or they use Kenneth Reitz' <code>Requests</code> library.</p>
  
  <p>Since my API calls rely on synchronous versions of requesting a URL, the whole process takes several minutes to complete.</p>
  
  <p>Now I'd like to wrap my API calls in async/await (asyncio). I'm using python 3.6.</p>
  
  <p>All the examples / tutorials that I found want me to change the synchronous URL calls / <code>requests</code> to an async version of it (for instance <code>aiohttp</code>). Since my code relies on API clients that I haven't written (and I can't change) I need to leave that code untouched.</p>
  
  <p><strong>So is there a way to wrap my synchronous requests (blocking code) in async/await to make them run in an event loop?</strong></p>
  
  <p>I'm new to asyncio in Python. This would be a no-brainer in NodeJS. But I can't wrap my head around this in Python. </p>