Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements a custom Rust async runtime to prevent GIL (Global Interpreter Lock) from stalling background Rust future tasks. This addresses PyO3/pyo3-async-runtimes issue #58 by replacing the external pyo3-async-runtimes dependency with an internal runtime implementation.
Key changes:
- Added custom async runtime module (
rt/) with task locals and thread-safe execution - Replaced all
pyo3_async_runtimes::tokiocalls with the newRuntimeimplementation - Added new exception type
RustPanicfor better error handling
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rt/mod.rs | Core runtime implementation with global Tokio runtime and task-local context management |
| src/rt/util.rs | Utility functions for setting Python future results and thread-safe callbacks |
| src/rt/task.rs | Task management with Python asyncio integration and context variable handling |
| src/rt/sync.rs | Synchronization primitives including cancellable futures and channel senders |
| src/lib.rs | Updated all HTTP method functions to use new Runtime instead of pyo3-async-runtimes |
| src/client/mod.rs | Updated client request methods to use new Runtime |
| src/client/resp/http.rs | Updated response processing to use new Runtime |
| src/client/resp/ws/mod.rs | Updated WebSocket operations to use new Runtime |
| src/client/resp/stream.rs | Updated streaming operations to use new Runtime |
| src/client/nogil.rs | Updated GIL-release functionality to use new Runtime |
| src/client/body/mod.rs | Updated body processing to use new Runtime |
| src/client/body/multipart.rs | Updated multipart form handling to use new Runtime |
| src/error.rs | Added new RustPanic exception type |
| Cargo.toml | Removed pyo3-async-runtimes dependency and added required tokio features |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
ref: PyO3/pyo3-async-runtimes#58