core: Do not close event loop too early#4819
Conversation
| # process, as when no tasks were offloaded the event-loop | ||
| # could hang up otherwise. | ||
| self._cleanup_bear(bear) | ||
| bears_without_tasks_to_cleanup.append(bear) |
There was a problem hiding this comment.
Can we keep this condition before looping over the tasks ?
Something like:
if not tasks:
bears_without_tasks_to_cleanup.append(bear)
continue
for task in tasks
...
Might not save too many clock cycles, but it will make code cleaner.
There was a problem hiding this comment.
Yeah why not, if you like I would also add an additional debug-message BearXYZ scheduled no tasks., so we still keep the information that a bear has been processed 👍
There was a problem hiding this comment.
Hm just thinking if this should be done in a separate commit... This commit diff is smaller when not shifting the logic away^^
There was a problem hiding this comment.
IMO this can be done in the same commit as we are adding this condition in this commit. It doesn't make sense to add something in first commit and change the same in subsequent one especially in same PR.
There was a problem hiding this comment.
And there won't be a case where we only want to rollback one of the commits and not the other one. So, its better to keep single commit.
There was a problem hiding this comment.
as we are adding this condition in this commit
which condition? The if is already there (if not tasks)
There was a problem hiding this comment.
Oh my bad. Can be done in different commit.
| # process, as when no tasks were offloaded the event-loop | ||
| # could hang up otherwise. | ||
| self._cleanup_bear(bear) | ||
| bears_without_tasks_to_cleanup.append(bear) |
There was a problem hiding this comment.
Oh my bad. Can be done in different commit.
| :param bears: | ||
| A list of bear instances to be scheduled onto the process pool. | ||
| """ | ||
| bears_without_tasks_to_cleanup = [] |
There was a problem hiding this comment.
bears_without_tasks_to_cleanup -> bears_without_tasks
| bears_without_tasks_to_cleanup.append(bear) | ||
|
|
||
| for bear in bears_without_tasks_to_cleanup: | ||
| # We need to recheck our runtime if something is left to process, as |
There was a problem hiding this comment.
Do we still need this comment ?
There was a problem hiding this comment.
hm yeah... I think this is more or less self explaining 👍
| self.assertEqual( | ||
| len(bear.dependency_results[BearA]), 1) | ||
|
|
||
| def test_run_many_dependency_bears_with_zero_tasks(self): |
There was a problem hiding this comment.
test_run_many_dependency_bears_with_zero_tasks -> test_run_multiple_dependency_bears_with_zero_tasks
| return (((i,), {}) for i in range(tasks_count)) | ||
|
|
||
|
|
||
| class DependentOnManyZeroTaskBearsTestBear(TestBearBase): |
There was a problem hiding this comment.
DependentOnManyZeroTaskBearsTestBear -> DependentOnMultipleZeroTaskBearsTestBear
There was a problem hiding this comment.
Just trying to be more accurate with words. 😃
231b747 to
76f25b0
Compare
76f25b0 to
aa720e2
Compare
|
ack aa720e2 |
|
ack a7b8e0b |
|
@gitmate-bot rebase |
... when scheduling all dependency bears. Bears that offload no tasks may cause the event-loop to close too early while other bears had no chance to submit their tasks. Fixes #4505
Moving the condition upwards makes code more understandable, as further scheduling code is not called at all because using now a `continue` statement. This change effectively doesn't change any behaviour, but makes control flow cleaner.
|
Hey! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost! |
|
Automated rebase was successful! |
aa720e2 to
5cbbe19
Compare
|
@rultor merge |
... when scheduling all dependency bears. Bears that offload no tasks
may cause the event-loop to close too early while other bears had no
chance to submit their tasks.
Fixes #4505