fix: close the motor client if an invalid db name raises in __init__ (mongo-9)

self._client[database] can raise InvalidName after the client is already
built, leaking it via any exception traceback the caller holds. close it
before re-raising, matching the __aenter__ leak fix. also compresses essay
docstrings/comments across the module with no behavior change, keeping the
swallow-and-default contract note and the matched_count/nInserted footguns.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-02 23:28:04 -04:00
parent 30f0e44097
commit 0a68b65937
4 changed files with 55 additions and 69 deletions
+3 -3
View File
@@ -8,18 +8,18 @@ helpers for the common paths, with a raw escape hatch for everything else.
`requirements.txt`:
```
mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v0.1.7
mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v0.1.8
```
Direct:
```bash
pip install "mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v0.1.7"
pip install "mongo @ git+ssh://git@git.rethinkstudios.io/rethink-public/mongo.git@v0.1.8"
```
Requires `motor` and `pymongo` (pulled transitively).
Drop the `@v0.1.7` suffix from the line above to install the latest unpinned.
Drop the `@v0.1.8` suffix from the line above to install the latest unpinned.
## Usage