Python async/await support
alexjpwalker opened this issue · 2 comments
Problem to Solve
Asynchronicity is not explicit.
Proposed Solution
We should consider use of the asyncio
library to enable an async/await syntax, much like what is used in Client NodeJS.
However, I'm currently 50/50 on this idea. While we do use async/await in client-nodejs, and it works well for highlighting remote calls that need to be awaited, as well as allowing people to execute remote calls in the background, it isn't exactly... pretty, at least in the Concept API when chaining multiple Concept API calls. Moreover, we don't have it in client-java.
But it may be nicer to use for users. We already had one request to support async and await.
Ideally, we should consult with experienced Python users to help make a call on this. We should also check if adding asyncio
breaks compatibility with existing code, or if it can be integrated seamlessly - since, probably, not everyone wants to be writing async and await everywhere when they use typedb-client
.
Interestingly, Mongo provides two Python drivers: one sync, one async. The async one, https://www.mongodb.com/docs/drivers/motor/, is compatible with both asyncio
and Tornado.
This appears to support the hypothesis that it's not easy or clean to support both the sync and async model in one package in Python.
We're for the time being not going to support an async python variant, since we cannot implement this over the Rust FFI boundary very easily after we have moved to a rust-core in our Python and Java drivers.