mongo-python-driver
mongo-python-driver copied to clipboard
PYTHON-4493 - Use asyncio protocols instead of sockets for network IO
Opening this now to begin the review process, as these changes are significant and especially critical to the driver's behavior.
Remaining TODOs:
- [ ] Ensure exhaust cursors fetch only
batch_sizemessages at a time, rather than all at once. - [ ] Verify our entire EG test suite passes
- [ ] Async performance benchmarks (PYTHON-5144)
A first review pass should focus on the structure of the code, especially PyMongoProtocol and async_receive_message.
PyMongoProtocol reads complete MongoDB wire protocol messages instead of raw bytes. This significantly increases the complexity of its read and buffer_updated methods, but allows us to maximize performance and encapsulate the wire protocol within.
For additional context on the Python Transport/Protocol API, see the official docs and this discuss thread that forms the backbone of our approach here.