biothings / myvariant.info

MyVariant.info: A BioThings API for human variant annotations
http://myvariant.info
Other
87 stars 32 forks source link

Apply new asyncio syntax and API #153

Closed erikyao closed 1 year ago

erikyao commented 1 year ago

Python 3.10 asyncio syntax and API should be applied across the myvariant.info code base. Specifically:

  1. delete all @asyncio.coroutine annotations; use async def to define a corotine
  2. use await instead of yield from to consume a corotine
  3. consider using asyncio.create_task() instead of asyncio.ensure_future() to schedule a task (which wraps a corotine).

Note that Goal 3 could be tricky because if a corotine is to be executed in another thread (e.g. the corotine JobManager.defer_to_thread()), asyncio.run_coroutine_threadsafe() should be used. See https://docs.python.org/3/library/asyncio-dev.html#concurrency-and-multithreading

Fixes will be pushed to branch py3.10_asyncio_pymongo4

erikyao commented 1 year ago

Fixed with PR https://github.com/biothings/myvariant.info/pull/157