Planning doc.
Now that the driver supports Python 3.6+, it may be technically feasible to have asyncio support directly in the driver, and offer both asynchronous and synchronous APIs from the same library.
Notionally we would convert the existing blocking methods to use async def and other async patterns with a new name like async_insert_one(). We would then use a decorator to provide the existing blocking methods by wrapping the async method. The decorator would wrap the method in a function that creates an event loop and runs the async method using coroutines or a thread pool if needed. It would also use the docstring for the wrapped method, perhaps translating any async-specific parts to synchronous language.
The research would be to spend some time trying out this method on a small subset of methods, and to think through the implications to thread-safety and preserving the existing APIs. We would also need to plan to have Motor act as a shim to the new APIs and eventually be deprecated.
- has to be done before
-
PYTHON-4561 Async PyMongo Full Release
- In Progress
- is related to
-
PYTHON-4549 Optimize Cursor.to_list
- Closed
- related to
-
PYTHON-3697 Add type hints for internal pymongo apis
- Released
-
MOTOR-762 Motor is not an async driver
- Closed