Skip to content

receive_event: Make it optionally semi-nonblocking #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nuclearcat
Copy link
Member

Right now receive_event is blocking, and even on receiving keep alive it stay inside its own busy loop, which makes impossible to implement proper scheduling, watchdogs, health monitoring.
We make optional parameter, where on keep alive message, (sent each 45 sec by kernelci-api) it will return None. We keep backward compatible defaults, as lot of code is not expecting None in return.

Copy link
Contributor

@pawiecz pawiecz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (functionally)

Argument semantics is non-obvious to me - shouldn't the event receiving loop be broken if the keep_alive value is False (this would require setting defaults to True and reversing loop condition)?

@JenySadadia
Copy link
Collaborator

The below code snippet in receive_event makes sure that it keeps on listening to events after BEEP is received:

if event.data == 'BEEP':
    continue

Instead of this workaround, I'd suggest we should check why receive_event loop blocks.

Right now receive_event is blocking, and even on receiving
keep alive it stay inside its own busy loop, which makes
impossible to implement proper scheduling, watchdogs,
health monitoring.
We make optional parameter, where on keep alive message,
(sent each 45 sec by kernelci-api) it will return None.
We keep backward compatible defaults, as lot of code is not
expecting None in return.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
@nuclearcat nuclearcat force-pushed the receive-event-nonblock branch from dbfc6ae to bfd42c9 Compare July 15, 2025 11:28
@nuclearcat
Copy link
Member Author

The below code snippet in receive_event makes sure that it keeps on listening to events after BEEP is received:

if event.data == 'BEEP':
    continue

Instead of this workaround, I'd suggest we should check why receive_event loop blocks.
While I understand it looks like a workaround, making receive_event non-blocking on keep-alive messages is the intended fix here.

The core issue is that the busy loop prevents other critical tasks from running. A deeper change to the event-receiving logic would be much more complex and might have unintended side effects. This approach gives us the scheduling flexibility we need while maintaining backward compatibility.
This PR is intended as a tactical fix for the scheduling problems, which hit us hard and caused builds outage for several days.
For more fundamental changes i am planning to redesign event system in near future.

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.

3 participants