masterhugo opened a new pull request, #3527:
URL: https://github.com/apache/tinkerpop/pull/3527
## Summary
Introduces five new classes alongside the existing sync WebSocket driver,
enabling applications to use gremlin-python inside a running asyncio event
loop without creating or blocking a thread-per-connection:
- `AsyncAiohttpWSTransport` – pure-coroutine WebSocket transport (aiohttp)
- `AsyncGremlinServerWSProtocol` – async protocol; offloads
deserialization to
the default executor so the event loop is never blocked by CPU work
- `AsyncResultSet` – `asyncio.Queue`-backed result set with async iteration
(`async for`) and coroutine `one()`/`all()` methods
- `AsyncConnection` – async connection with lazy connect; background
asyncio
Task drains partial (206) responses without blocking the caller
- `AsyncClient` – drop-in async counterpart to `Client`; uses
`asyncio.Queue`
for the connection pool and exposes `async
submit`/`submit_async`/`close`;
supports the async context-manager protocol
No existing code is modified — all sync WebSocket and HTTP paths are
unchanged.
## Motivation
Python async/await (`asyncio`) is now the standard concurrency model for
Python web frameworks (FastAPI, Starlette, aiohttp). Applications that run
inside an event loop cannot use the existing sync `Client` without blocking
the loop or running it in a thread. These classes fill that gap without
touching the existing API surface.
## Test plan
- [ ] 48 new unit tests using `unittest.IsolatedAsyncioTestCase` (stdlib,
no additional test dependencies):
pytest tests/unit/driver/test_async_websocket.py
- [ ] Full unit suite passes: `pytest tests/unit/`
- [ ] Integration tests via Docker Compose:
docker compose up --build --abort-on-container-exit
gremlin-python-integration-tests
## Checklist
- [x] ASF license header added to all new files
- [x] `CHANGELOG.asciidoc` updated
- [x] No existing public APIs, serialization formats, or network protocols
modified
- [x] No new dependencies introduced (uses `aiohttp` which is already a
dependency)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]