refactor: asyncio for better cancellation handling#16
Merged
Conversation
41b7e16 to
494a7bb
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the codebase to use asyncio for improved error handling and graceful subprocess cancellation. When an error occurs in any parallel branch of the conversion pipeline, all running subprocesses can now be terminated gracefully using asyncio's TaskGroup.
Key Changes:
- Migrated from
ThreadPoolExecutortoasyncio.TaskGroupfor concurrent task execution - Converted all subprocess calls to use async wrappers for better cancellation handling
- Bumped minimum Python version requirement from 3.10 to 3.11 (required for
TaskGroup)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| utils.py | Added async run() wrapper for subprocess execution with cancellation support and syncify() decorator to bridge async functions with synchronous callers |
| pyproject.toml | Updated minimum Python version to 3.11 to support asyncio.TaskGroup |
| pdfservices.py | Converted export() function to async and added yield points for task switching |
| main.py | Refactored pipeline to use TaskGroup instead of ThreadPoolExecutor, converted all helper functions to async |
| CHANGELOG.md | Documented the asyncio refactoring and Python version bump |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7ce8811 to
dc34877
Compare
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.
With asyncio, we're now able to terminate subprocesses gracefully whenever an
error is first encountered in any branch.