-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Replace get_event_loop with get_running_loop in the compressor #9780
Conversation
> Deprecated since version 3.12: Deprecation warning is emitted if there is no current event loop. In some future Python release this will become an error
CodSpeed Performance ReportMerging #9780 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #9780 +/- ##
=======================================
Coverage 98.68% 98.69%
=======================================
Files 117 118 +1
Lines 35968 35996 +28
Branches 4276 4278 +2
=======================================
+ Hits 35494 35525 +31
+ Misses 319 316 -3
Partials 155 155
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Looks like we have some missing coverage here |
Backport to 3.10: 💚 backport PR created✅ Backport PR branch: Backported as #9788 🤖 @patchback |
(cherry picked from commit eac8fb8)
Backport to 3.11: 💚 backport PR created✅ Backport PR branch: Backported as #9789 🤖 @patchback |
(cherry picked from commit eac8fb8)
@@ -79,8 +87,8 @@ async def compress(self, data: bytes) -> bytes: | |||
self._max_sync_chunk_size is not None | |||
and len(data) > self._max_sync_chunk_size | |||
): | |||
return await asyncio.get_event_loop().run_in_executor( | |||
self._executor, self.compress_sync, data | |||
return await asyncio.get_running_loop().run_in_executor( |
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.
Should we replace these low-level calls with asyncio.to_thread() now that we don't support 3.8?
…nning_loop in the compressor (#9788) Co-authored-by: J. Nick Koston <[email protected]>
…nning_loop in the compressor (#9789) Co-authored-by: J. Nick Koston <[email protected]>
What do these changes do?
Replace
get_event_loop
withget_running_loop
in the compressor. This should never be called without a running event loop as its in an async function.asyncio.get_event_loop
:There was no need to call the sync wrapper function since we are already inside the object and can call the compressor/decompressor directly.
Adds missing test coverage
Are there changes in behavior for the user?
no
Is it a substantial burden for the maintainers to support this?
no