Skip to content

Allow finite filescan task groups to finish - #1180

Merged
mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/filescan-finite-task-group-exit-20261007
Oct 7, 2026
Merged

mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/filescan-finite-task-group-exit-20261007

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Fixes #1177.

Separate the persistent signal listener from the user-work task group, then cancel the listener after finite work finishes. The listener no longer blocks normal context exit or prevents run_as_main from returning its result.

Finite children are allowed to finish rather than being cancelled early. Signal handling stays active while they drain; explicit forever mode, callbacks and error propagation remain covered. Exceptions may be nested in task-group exception groups. This changes the task-group helper, not the scanner daemon request loop.

Testing

python -m pytest -q filescan/python-filescan/tests/test_finite_task_group.py

19 focused tests passed; seven fail on unchanged main. Tests run on asyncio and Trio and cover empty/finite child groups, sequential use, callbacks, body/child/callback failures, explicit forever mode and cancellation while draining children.

The run_as_main return check and real SIGINT/SIGTERM checks run in separate Python processes with parent-enforced timeouts. Signals target only each test process itself. No scanner daemon, Redis service or external endpoint is used. Trio is an optional test backend and is skipped when not installed.

89 tests passed in an isolated combined check containing these three fixes and the current #1155, #1166 and #1174 changes. That run includes the existing timezone and worker-cancellation regressions; the separate chunk-size suite was not rerun. No earlier production changes are included in this PR.

Tested on macOS with Python 3.12 and the pinned AnyIO 4.14.2. New-test formatting, scoped syntax/lint checks and git diff --check pass. No dependency or workflow changes. Full Malcolm deployment testing was not run.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@mmguero mmguero self-assigned this Oct 7, 2026
@mmguero mmguero added the pipeline Relating to carving (extraction) of files from traffic and the scanning of those files label Oct 7, 2026
@mmguero mmguero added this to Malcolm Oct 7, 2026
@mmguero mmguero added this to the v26.10.0 milestone Oct 7, 2026
@mmguero
mmguero changed the base branch from main to sylvesterkaczmarek-merges October 7, 2026 15:54
@mmguero
mmguero merged commit a9d3b83 into cisagov:sylvesterkaczmarek-merges Oct 7, 2026
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Thanks @mmguero — appreciate you merging both #1180 and #1179.

@mmguero mmguero moved this from Done to Released in Malcolm Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipeline Relating to carving (extraction) of files from traffic and the scanning of those files

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

Finite filescan task groups hang after their work completes

2 participants