Skip to content

fix(event): suppress native asyncio.QueueShutDown on Python 3.13+#6773

Open
axelray-dev wants to merge 1 commit into
reflex-dev:mainfrom
axelray-dev:fix/queue-shutdown-py313
Open

fix(event): suppress native asyncio.QueueShutDown on Python 3.13+#6773
axelray-dev wants to merge 1 commit into
reflex-dev:mainfrom
axelray-dev:fix/queue-shutdown-py313

Conversation

@axelray-dev

Copy link
Copy Markdown

Summary

On Python 3.13+, asyncio.Queue.shutdown() makes queue.get() raise the stdlib asyncio.QueueShutDown. EventProcessor only suppressed a local subclass of that exception, so the native instance was treated as an unexpected processor error and could emit error logs/telemetry during normal stop.

Changes

  • Catch/suppress the native asyncio.QueueShutDown (when present) in _process_queue and stop.
  • Keep the pre-3.13 local QueueShutDown fallback for artificial raises.
  • Add a unit regression that shuts down a native queue and asserts stop/process does not call telemetry/console error helpers.

Verification

  • uv run pytest tests/units/reflex_base/event/processor/test_event_processor.py -q (37 passed)
  • Ruff and targeted Pyright clean on touched files

Backwards compatibility

No public API change. Pre-3.13 behavior unchanged. Stop still drains and cancels as before; only expected shutdown exceptions are ignored correctly.

Fixes #6756

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent error during normal shutdown on Python 3.13+ where asyncio.Queue.shutdown() raises the stdlib asyncio.QueueShutDown directly, but the processor only suppressed its own local subclass — causing the native instance to fall through to the telemetry/console error path.

  • Introduces _QUEUE_SHUTDOWN_ERRORS, a module-level tuple set to (asyncio.QueueShutDown,) on Python 3.13+ (covering both the native class and the local subclass via inheritance) and (QueueShutDown,) on older Python, then applies it in both _process_queue (contextlib.suppress) and stop() (except clause).
  • Adds a @pytest.mark.skipif regression test that shuts down a native queue, exercises both the _process_queue and stop() code paths, and asserts neither telemetry.send_error nor console.error is called.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to exception handling during queue shutdown and has no effect on the happy path.

Both changed sites have a clear before/after: the contextlib.suppress and the except clause now include the native stdlib exception type on Python 3.13+, and the pre-3.13 path is unchanged. The new test exercises both code paths and mocks the two sinks that would have fired incorrectly. No public API is touched.

No files require special attention.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/event/processor/event_processor.py Introduces _QUEUE_SHUTDOWN_ERRORS tuple to cover both the native asyncio.QueueShutDown (Python 3.13+) and the local fallback subclass; uses it in _process_queue and stop() so the native exception is suppressed during normal shutdown rather than surfaced as a processor error
tests/units/reflex_base/event/processor/test_event_processor.py Adds a regression test (test_native_queue_shutdown_is_suppressed) skipped below Python 3.13 that shuts down a native asyncio.Queue, directly calls _process_queue, and triggers the stop() queue-task path, asserting neither telemetry.send_error nor console.error is invoked

Reviews (1): Last reviewed commit: "fix(event): suppress native asyncio.Queu..." | Re-trigger Greptile

@axelray-dev axelray-dev marked this pull request as ready for review July 15, 2026 10:58
@axelray-dev axelray-dev requested a review from a team as a code owner July 15, 2026 10:58
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.

QueueShutDown subclass doesn't catch native asyncio.QueueShutDown on Python 3.13+ — spurious error logged on every shutdown

1 participant