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
+
This section describes the layout of the `pymongo/` package.
512
511
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.
512
+
Within `pymongo/`, the code is further divided into the `pymongo/asynchronous` and `pymongo/synchronous` subdirectories.
513
+
Files in `pymongo/synchronous` are generated from `pymongo/asynchronous` using the `synchro` pre-commit hook, which uses [unasync](https://github.com/python-trio/unasync/) and some custom transforms.
514
+
515
+
As a result, **all modifications** within `pymongo` must be made in either the top-level `pymongo` directory when they have to exhibit differing behavior between sync and async contexts or the `pymongo/asynchronous` directory, not `pymongo/synchronous`.
516
+
Any changes made directly to files in the `pymongo/synchronous` directory will be overwritten by the `synchro` hook when it is run, which happens automatically on commit.
517
+
518
+
Some top-level files (e.g. `pymongo/collection.py`) are re-export files for existing import compatibility and should not be modified directly.
519
+
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`.
520
+
521
+
Run `pre-commit run --all-files synchro` before running tests to generate the latest version of the synchronous code.
515
522
516
523
To prevent the `synchro` hook from accidentally overwriting code, it first checks to see whether a sync version
517
524
of a file is changing and not its async counterpart, and will fail.
0 commit comments