-
-
Notifications
You must be signed in to change notification settings - Fork 421
Force task switch every 2000 rows when creating objects #1939
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
base: develop
Are you sure you want to change the base?
Force task switch every 2000 rows when creating objects #1939
Conversation
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.
Pull Request Overview
This PR addresses event loop blocking by forcing a task switch every 2000 rows while processing large result sets.
- Introduces a CHUNK_SIZE constant to define the row interval for yielding.
- Modifies the loop over raw results to use enumerate and conditionally await asyncio.sleep(0) for a task switch.
CodSpeed Performance ReportMerging #1939 will not alter performanceComparing Summary
|
Pull Request Test Coverage Report for Build 14718896345Details
💛 - Coveralls |
bac6883
to
11626dc
Compare
@@ -24,10 +30,6 @@ Added | |||
^^^^^ | |||
- `.only` supports selecting related fields, e.g. `.only("related__field")` (#1923) | |||
|
|||
Fixed |
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.
Removed a duplicate
Description
When selecting a large number of records, the process of converting database records to Tortoise objects might completely block the event loop. This PR introduces a task switch every 2000 rows to allow other workloads.
Motivation and Context
Fixes #1378.
I remember seeing other similar issues.
How Has This Been Tested?
make ci
and testing it in my hobby project.Checklist: