Skip to content

PLATCO-153: uvloop compatibility#2

Merged
adriaardila merged 7 commits intomasterfrom
feature/PLATCO-153_uvloop_compatibility
Jan 23, 2026
Merged

PLATCO-153: uvloop compatibility#2
adriaardila merged 7 commits intomasterfrom
feature/PLATCO-153_uvloop_compatibility

Conversation

@adriaardila
Copy link
Collaborator

Added uvloop compatibility

@adriaardila adriaardila self-assigned this Jan 23, 2026
Copilot AI review requested due to automatic review settings January 23, 2026 14:12
Copy link

Copilot AI left a 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 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 of asyncio.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.

@adriaardila adriaardila merged commit 193a936 into master Jan 23, 2026
4 checks passed
@adriaardila adriaardila deleted the feature/PLATCO-153_uvloop_compatibility branch January 23, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments