Skip to content

refactor: asyncio for better cancellation handling#16

Merged
sghng merged 13 commits intomainfrom
refactor/asyncio
Nov 16, 2025
Merged

refactor: asyncio for better cancellation handling#16
sghng merged 13 commits intomainfrom
refactor/asyncio

Conversation

@sghng
Copy link
Owner

@sghng sghng commented Nov 15, 2025

With asyncio, we're now able to terminate subprocesses gracefully whenever an
error is first encountered in any branch.

@sghng sghng changed the title bump min python to 3.11 refactor: asyncio for better cancellation handling Nov 15, 2025
Copy link
Contributor

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 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 ThreadPoolExecutor to asyncio.TaskGroup for 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.

@sghng sghng linked an issue Nov 16, 2025 that may be closed by this pull request
@sghng sghng merged commit 779eeac into main Nov 16, 2025
@sghng sghng deleted the refactor/asyncio branch November 23, 2025 06:12
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.

Use asyncio to terminate the subprocesses early if errors occur

2 participants