You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow the [Python Driver Release Process Wiki](https://wiki.corp.mongodb.com/display/DRIVERS/Python+Driver+Release+Process).
507
507
508
-
## Asyncio considerations
508
+
## Project Structure and Asyncio Considerations
509
509
510
-
PyMongo adds asyncio capability by modifying the source files in `*/asynchronous`to `*/synchronous`using
511
-
[unasync](https://github.com/python-trio/unasync/) and some custom transforms.
510
+
PyMongo's source code is located in the `pymongo` directory and is further divided into the `pymongo/asynchronous`and `pymongo/synchronous`subdirectories.
511
+
All files in the `synchronous` subdirectory are generated from the `asynchronous` subdirectory using the `synchro` pre-commit hook, which uses [unasync](https://github.com/python-trio/unasync/) and some custom transforms.
512
512
513
-
Where possible, edit the code in `*/asynchronous/*.py` and not the synchronous files.
514
-
You can run `pre-commit run --all-files synchro` before running tests if you are testing synchronous code.
513
+
As a result, **all modifications** must be made in the top-level `pymongo` directory or the `pymongo/asynchronous` directory.
514
+
Any changes made to files in the `pymongo/synchronous` directory will be overwritten by the `synchro` hook when it is run, which happens automatically on commit.
515
+
516
+
Some top-level files (e.g. `pymongo/collection.py`) are re-export files for existing import compatibility and should not be modified directly.
517
+
The other top-level files (e.g. `pymongo/network_layer.py`, `pymongo/pool_shared.py`) contain either shared code used in both the asynchronous and synchronous APIs, or code that is very different between the two APIs and therefore cannot be generated from the async version using `synchro`.
518
+
519
+
You can run `pre-commit run --all-files synchro` before running tests to generate the latest version of the synchronous code.
515
520
516
521
To prevent the `synchro` hook from accidentally overwriting code, it first checks to see whether a sync version
517
522
of a file is changing and not its async counterpart, and will fail.
0 commit comments