Skip to content

Comments

Call task_done() for stop sentinel in dispatch_events#1159

Merged
BoboTiG merged 2 commits intogorakhargosh:masterfrom
bysiber:fix/dispatch-events-task-done
Feb 20, 2026
Merged

Call task_done() for stop sentinel in dispatch_events#1159
BoboTiG merged 2 commits intogorakhargosh:masterfrom
bysiber:fix/dispatch-events-task-done

Conversation

@bysiber
Copy link
Contributor

@bysiber bysiber commented Feb 20, 2026

BaseObserver.dispatch_events calls event_queue.get() to pull items off the queue. For normal events, it dispatches them to handlers and then calls event_queue.task_done(). However, when it receives the stop sentinel, it returns immediately without calling task_done().

Queue.task_done() must be called once for every get() to keep the queue's internal unfinished-task counter accurate. Skipping it means the counter is permanently off by one, causing any subsequent event_queue.join() to block indefinitely.

The fix adds the missing task_done() call on the stop-event path, before return.

When dispatch_events receives the stop sentinel from the event queue,
it returns immediately without calling event_queue.task_done(). This
leaves the queue's internal unfinished-task counter permanently off by
one, so any subsequent event_queue.join() will block forever.

Add the missing task_done() call before returning on the stop path.
@BoboTiG
Copy link
Collaborator

BoboTiG commented Feb 20, 2026

A line in the changelog and I'll merge, thanks for spotting this one!

@bysiber
Copy link
Contributor Author

bysiber commented Feb 20, 2026

Added a changelog entry. Thanks for the review!

1 similar comment
@bysiber
Copy link
Contributor Author

bysiber commented Feb 20, 2026

Added a changelog entry. Thanks for the review!

@BoboTiG BoboTiG merged commit eadfc8c into gorakhargosh:master Feb 20, 2026
30 checks passed
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.

2 participants