Skip to content
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

Merged
merged 3 commits into from
Nov 10, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 10, 2024

What do these changes do?

Replace get_event_loop with get_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:

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

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

> 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
@bdraco bdraco added bot:chronographer:skip This PR does not need to include a change note backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot labels Nov 10, 2024
Copy link

codspeed-hq bot commented Nov 10, 2024

CodSpeed Performance Report

Merging #9780 will not alter performance

Comparing compress_get_running_loop (02655d5) with master (2f6ff6d)

Summary

✅ 16 untouched benchmarks

Copy link

codecov bot commented Nov 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.69%. Comparing base (c5bf577) to head (02655d5).
Report is 3 commits behind head on master.

✅ 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           
Flag Coverage Δ
CI-GHA 98.58% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.26% <100.00%> (+<0.01%) ⬆️
OS-Windows 96.04% <100.00%> (+0.01%) ⬆️
OS-macOS 97.34% <100.00%> (+0.01%) ⬆️
Py-3.10.11 97.19% <100.00%> (+0.01%) ⬆️
Py-3.10.15 97.79% <100.00%> (+0.01%) ⬆️
Py-3.11.10 97.79% <100.00%> (+0.01%) ⬆️
Py-3.11.9 97.23% <100.00%> (+0.01%) ⬆️
Py-3.12.7 98.33% <100.00%> (+0.01%) ⬆️
Py-3.13.0 98.26% <100.00%> (-0.05%) ⬇️
Py-3.9.13 97.10% <100.00%> (+<0.01%) ⬆️
Py-3.9.20 97.70% <100.00%> (+0.01%) ⬆️
Py-pypy7.3.16 97.27% <100.00%> (+0.01%) ⬆️
VM-macos 97.34% <100.00%> (+0.01%) ⬆️
VM-ubuntu 98.26% <100.00%> (+<0.01%) ⬆️
VM-windows 96.04% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco
Copy link
Member Author

bdraco commented Nov 10, 2024

Looks like we have some missing coverage here

@bdraco bdraco marked this pull request as draft November 10, 2024 20:07
@bdraco bdraco marked this pull request as ready for review November 10, 2024 21:52
@bdraco bdraco merged commit eac8fb8 into master Nov 10, 2024
40 of 41 checks passed
@bdraco bdraco deleted the compress_get_running_loop branch November 10, 2024 22:08
Copy link
Contributor

patchback bot commented Nov 10, 2024

Backport to 3.10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.10/eac8fb84417fd55128e2263f60ef3efa6ba51abd/pr-9780

Backported as #9788

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link
Contributor

patchback bot commented Nov 10, 2024

Backport to 3.11: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.11/eac8fb84417fd55128e2263f60ef3efa6ba51abd/pr-9780

Backported as #9789

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@@ -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(
Copy link
Member

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?

bdraco added a commit that referenced this pull request Nov 10, 2024
…nning_loop in the compressor (#9788)

Co-authored-by: J. Nick Koston <[email protected]>
bdraco added a commit that referenced this pull request Nov 10, 2024
…nning_loop in the compressor (#9789)

Co-authored-by: J. Nick Koston <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot bot:chronographer:skip This PR does not need to include a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants