Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces explicit uvloop compatibility by changing how slow-task detection patches the event loop, adding uvloop-specific tests and benchmarks, and updating docs and metadata to reflect uvloop support.
Changes:
- Refactors slow-task detection to patch event loop scheduling methods (
call_soon,call_later, etc.) instead ofasyncio.Handle._run, making it compatible with uvloop. - Adds uvloop-focused tests and benchmark support (including CLI flags and comparative output) to validate behavior and measure overhead on uvloop.
- Updates package metadata, docs, and README to advertise uvloop support and document the new architecture and performance characteristics.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Bumps aiocop to 1.1.0 and adds uvloop (non-Windows) to the locked dependencies, ensuring uvloop is available for tests/benchmarks. |
pyproject.toml |
Updates project version/description and adds uvloop to the test extra on non-Windows platforms so uvloop tests can run via extras. |
tests/test_uvloop.py |
Introduces a new test module that runs aiocop under uvloop.run(), verifying blocking I/O detection, severity, context providers, threshold flags, and that the uvloop event loop gets patched and marked as such. |
aiocop/core/state.py |
Adds an internal on-activate hook registry plus register_on_activate_hook, allowing slow-task detection to patch the running loop lazily when activate() is called. |
aiocop/core/slow_tasks.py |
Reimplements slow-task detection by patching the loop’s scheduling methods (including call_soon_threadsafe) with a monitored wrapper that captures blocking events and severity, compatible with both asyncio and uvloop and wired into the new on-activate hook. |
aiocop/core/callbacks.py |
Makes error logging for context providers and slow-task callbacks more robust by not assuming __name__ exists, improving diagnostics for non-function callables. |
aiocop/exceptions.py |
Tightens typing of HighSeverityBlockingIoException.events to use BlockingEventInfo (via TYPE_CHECKING), aligning the exception type with the event model. |
benchmarks/run_benchmark.py |
Extends the benchmark script to support asyncio vs uvloop modes, structured results (per-loop and comparison), CLI flags (--asyncio-only / --uvloop-only), state reset between runs, and uvloop-based execution via uvloop.run(). |
docs/installation.md |
Notes optional uvloop support in installation requirements, clarifying that aiocop works with both asyncio and uvloop. |
docs/index.md |
Adds a feature bullet stating aiocop works with both standard asyncio and uvloop. |
docs/guide.md |
Updates the internal architecture description to explain that aiocop now patches loop scheduling methods (call_soon/call_later/call_at) instead of Handle._run, explicitly noting this works with uvloop. |
docs/benchmarks.md |
Expands benchmarks to include uvloop-specific results, a side-by-side asyncio vs uvloop comparison, and updated CLI usage examples that mirror the new benchmark script. |
docs/api.md |
Updates the detect_slow_tasks API description to say it patches “the event loop” and works with both asyncio and uvloop. |
README.md |
Advertises asyncio+uvloop compatibility, updates the architecture explanation to refer to patching scheduling methods, and adds uvloop to the comparison table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MindfulPol
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added uvloop compatibility