Fix async life cycle management to prevent lost references to tasks. - #157 - #158
Open
sebastiaan-la-fleur wants to merge 9 commits into
Open
sebastiaan-la-fleur wants to merge 9 commits into
sebastiaan-la-fleur wants to merge 9 commits into
Conversation
sebastiaan-la-fleur
marked this pull request as ready for review
September 23, 2026 11:46
sebastiaan-la-fleur
requested review from
jorritn and
wcoenraads
as code owners
September 23, 2026 11:46
…pyright on tox.ini typecheck command.
| @@ -0,0 +1,82 @@ | |||
| name: Check Python | |||
Member
Author
There was a problem hiding this comment.
Sorry for also fixing CI in this PR, but we were running into some annoying issues that prevented the actual fix from succeeding in CI.
Copilot stopped reviewing on behalf of
sebastiaan-la-fleur due to an error
September 23, 2026 13:32
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 4
Open (4)
Unquoted$@will word-split and glob-expand arguments (breaking flags that contain spaces and… · Newasyncio.get_event_loop()is deprecated in some contexts and can behave differently across Python… · New This overwrites any existingPYTHONPATHin the environment, which can break developer/CI setups… · New With multiplepylintcommands, tox will stop at the first failure, which can hide additional lint… · New
What changed in this PR
Updates the async connection’s task-lifecycle handling and expands the project’s quality gates (lint/typecheck/CI) while adding targeted unit tests to validate cancellation/stop/exception behavior.
Changes:
- Refactors
S2AsyncConnection.run()andsend_msg_and_await_reception_status()to more reliably cancel/drain background tasks and surface/log exceptions. - Adds new async connection lifecycle unit tests and tweaks existing unit-test formatting.
- Expands tooling: runs
pyrightin typecheck, adjusts lint configuration for tests, and refactors GitHub Actions CI into a reusable workflow.
| File | Description |
|---|---|
| tox.ini | Adjusts lint/typecheck commands; adds PYTHONPATH for lint; runs pyright in tox typecheck env. |
| tests/unit/reception_status_awaiter_test.py | Reformats list comprehensions for readability. |
| tests/unit/connection/async_/connection_test.py | Adds new unit tests covering async connection task management and cancellation/stop scenarios. |
| src/s2python/connection/async_/connection.py | Refactors background task creation/cancellation/draining and exception logging. |
| pyrightconfig.json | Adds a tests execution environment and relaxes a specific diagnostic for tests. |
| pyproject.toml | Raises minimum setuptools version. |
| mypy.ini | Disables additional mypy error codes for a test-related section. |
| dev-requirements.txt | Regenerates dev requirements (Python 3.9) and adds backports needed for older runtimes. |
| ci/typecheck.sh | Aggregates mypy + pyright exit status so both run and report failures. |
| ci/test_unit.sh | Allows passing through extra pytest args. |
| ci/setup_dev_environment.sh | Switches venv creation to Python 3.9. |
| ci/lint.sh | Splits linting for src/examples vs tests with different pylint settings. |
| AGENTS.md | Adds contributor/development guidelines and tooling conventions. |
| .pylintrc | Keeps certain checks enabled globally; relies on entry points to disable for tests. |
| .github/workflows/ci.yml | Replaces per-job definitions with a reusable workflow and updates publish jobs. |
| .github/workflows/check-python.yml | New reusable workflow to build/test/lint/typecheck per Python version. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.

PR does 2 things: