Skip to content

fix(notifier): ignore queued messages after stopping - #2110

Open
timothyanderson096-ocdealcheck wants to merge 1 commit into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/notifier-queued-delivery-1712
Open

timothyanderson096-ocdealcheck wants to merge 1 commit into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/notifier-queued-delivery-1712

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Fixes #1712.

With an asyncio loop configured, a Notifier can queue a message delivery before stop() closes its listeners. That queued delivery can later call a log writer and raise "I/O operation on closed file".

Check the stopped state before each listener callback. This prevents queued deliveries from reaching stopped listeners and stops delivery to remaining listeners when a callback calls stop(). Already-scheduled coroutine tasks and callbacks currently executing on another thread remain outside this fix.

The regression uses a real CanutilsLogWriter backed by StringIO and checks both the closed stream and the event loop's error handler. Additional coverage checks delivery before shutdown, reentrant stop and active-listener error reporting. Both shutdown regressions fail on unmodified main and pass with the guard.

Validation on Linux, based on main b4f82ab:

  • tox -e py312 -- test/notifier_test.py test/listener_test.py: 18 passed.
  • tox run-parallel -e lint,type,docs: all passed.
  • git diff --check: passed.

The full suite was not repeated: a same-base run earlier in this environment had 28 IPv4/IPv6 multicast failures due to unavailable network routes. No physical CAN hardware was used. The async exception-routing work in #2096 addresses a separate path. Prepared with AI assistance and independently reviewed.


Timothy Anderson — Spotted Ridge Engineering / OC Labs
GDN — Global Decision Network
timothyanderson096@gmail.com · Engineering evidence

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T04:15:12.851583Z b4457a6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

I/O Operation on closed file

1 participant