Skip to content
This repository was archived by the owner on Dec 21, 2025. It is now read-only.

Conversation

@mwerezak
Copy link

Fix IndexError from being raised inside the kernel by turning SchedFIFO wake into a no-op if there are no tasks waiting.

See discussion on #365.

def _kernel_wake(self, ntasks=1):
tasks = []
while ntasks > 0:
while ntasks > 0 and len(self._queue) > 0:
Copy link

@x42005e1f x42005e1f Oct 17, 2025

Choose a reason for hiding this comment

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

I think that truth testing will also be sufficient:

while self._queue and ntasks > 0:
    ...

This is the same as checking the length for non-zero (it cannot be less than zero anyway), but it takes fewer bytecode instructions. And this pattern is also present in the existing code base.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants