PyMongo 4.17 Released

PyMongo 4.17 Released

We’re happy to announce the release of PyMongo 4.17, available now on PyPI.

What’s new

Session binding — The new ClientSession.bind() / AsyncClientSession.bind() context manager lets you bind a session to all database operations within a block, eliminating the need to pass the session explicitly to every individual call. This makes transaction code significantly cleaner.

with session.bind():
    db.users.insert_one({"name": "Alice"})  # session applied automatically
    db.orders.insert_one({"user": "Alice", "total": 42})

See the Transactions docs for more.

Intelligent Workload Management (IWM) support — PyMongo now gracefully handles write-blocking scenarios and optimizes connection establishment under high load. This improves application availability when MongoDB Atlas IWM or ingress connection rate limiting is active. See the IWM docs and Overload Errors docs for details.

Deprecations

bson.son.SON methods has_key(), iterkeys(), and itervalues() are deprecated and will be removed in PyMongo 5.0. Use the standard in operator, .keys(), and .values() instead.

Install / upgrade

pip install pymongo==4.17.0

As always, please open an issue on JIRA if you run into any problems.