-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): More robust handling of async
database calls
#15202
feat(python): More robust handling of async
database calls
#15202
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15202 +/- ##
==========================================
- Coverage 81.25% 81.24% -0.01%
==========================================
Files 1354 1354
Lines 175390 175406 +16
Branches 2518 2520 +2
==========================================
+ Hits 142505 142506 +1
- Misses 32404 32417 +13
- Partials 481 483 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add tests for the cases this is trying to solve? And add nest_asyncio
to the requirements-dev.txt
.
Will see what I can come up with; shouldn't be too hard to setup an outer
Done (had it in the other branch, but missed copying it over 😅) |
Done; created/committed a test that simulates the event loop conditions found inside Notebooks and other nested (If you comment out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Alex, I think we can go ahead with this 👍
I'm only thinking that maybe we can add a warning to the read_database
docstring that using async engines is currently considered unstable. That way at least we have some leeway if we choose to go for a different solution in the near future. I'll let you be the judge.
Sounds like a good idea to me; I'll label the support as being considered experimental for now in my imminent follow-up (coming later tonight or first thing tomorrow) that adds SurrealDB support 😎👍 |
Ref: #15162 (comment)
@stinodego: This brings forward additional
async
industrialisation that I was working on yesterday, while adding some initialSurrealDB
1 integration (have got a newSurrealDBCursorProxy
class working in another branch2).I haven't been able to reproduce the
ResourceWarning
locally yet, but this may solve it by explicitly closing any event loops that we know we created in-context (and it doesn't seem to have occurred in these tests, so... maybe? 🤔)Also improves/fixes interaction with Notebooks/Jupyter (nesting
asyncio
calls).Footnotes
SurrealDB features: https://surrealdb.com/features ↩
SurrealDB + Polars: https://github.com/surrealdb/surrealdb.py/pull/91#issuecomment-2009802667 ↩