Fix async life cycle management to prevent lost references to tasks. - #157 - #158
Conversation
…pyright on tox.ini typecheck command.
| @@ -0,0 +1,82 @@ | |||
| name: Check Python | |||
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.
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.
jorritn
left a comment
There was a problem hiding this comment.
Looks good! Great improvement. I only reviewed the life cycle management part, not the ci part.

PR does 2 things: