title: How do I list databases with the python asyncio mongo client, motor?
body: <p>I'm having problems get <a href="https://motor.readthedocs.io/en/stable/" rel="nofollow noreferrer">motor</a> to list databases with asyncio.</p>
  <p>The following code:</p>
  <pre class="lang-py prettyprint-override"><code>import asyncio
  import motor.motor_asyncio
  import sys
  
  async def list():
      print(sys.version)
      print(motor.version)
      client = motor.motor_asyncio.AsyncIOMotorClient(&quot;mongodb://admin:password@mongo/&quot;)
      for db in client.list_databases():
          print(db)
          print(type(db))
          await db
  
  
  loop = asyncio.get_event_loop()
  loop.run_until_complete(list())
  </code></pre>
  <p>fails with the following error</p>
  <pre class="lang-py prettyprint-override"><code>2.1.0
  3.8.5 (default, Jul 21 2020, 10:48:26) 
  [Clang 11.0.3 (clang-1103.0.32.62)]
  &lt;Future pending cb=[run_on_executor.&lt;locals&gt;._call_check_cancel() at /usr/local/lib/python3.8/site-packages/motor/frameworks/asyncio/__init__.py:80]&gt;
  &lt;class '_asyncio.Future'&gt;
  Traceback (most recent call last):
    File &quot;test.py&quot;, line 17, in &lt;module&gt;
      loop.run_until_complete(list())
    File &quot;/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py&quot;, line 616, in run_until_complete
      return future.result()
    File &quot;test.py&quot;, line 13, in list
      await db
  RuntimeError: await wasn't used with future
  </code></pre>
  <p>I found this issue which seems related <a href="https://bugs.python.org/issue37172" rel="nofollow noreferrer">https://bugs.python.org/issue37172</a>. This also seems to fail with python 3.7.7 and motor 2.0.0.</p>
  <p>As a horrible work around at the moment, I'm using <code>pymongo</code> exclusively for this operation - but I would prefer not to do this.</p>