-
Notifications
You must be signed in to change notification settings - Fork 18
Fix test typing #1235
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
base: v1.x.x
Are you sure you want to change the base?
Fix test typing #1235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates a test to avoid passing None
and instead validates behavior with an empty config dict, aligning with current type hints.
- Renames test from
test_load_config_load_None
totest_load_config_load_empty
- Updates the docstring to describe the empty-config edge case
- Changes the
load_config
call to pass the entireconfig
dict instead ofconfig.get("loggers", None)
Comments suppressed due to low confidence (1)
tests/config/test_util.py:57
- [nitpick] The test name
test_load_config_load_empty
repeats 'load'. Consider renaming it totest_load_config_empty
for clarity.
def test_load_config_load_empty(
Fixes the underlying problem preventing #1234 from proceeding |
a524089
to
2e24f61
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested improvements to the tests are completely optional, not approving only because I think we should not add stuff that users don't care about in the release notes.
2e24f61
to
abeae86
Compare
3e55f21
to
e28a775
Compare
hmm maybe my fix 45c4ad7 |
Previously there was a test which violated type-hints. As we can not keep having the test _and_ type hints on that test, the test itself was rewritten to test a semantically slightly different but similar edge case. The original test case is of course prevented when using type-hints (i.e not passing `None` to a function that doesn't accept `None`)
Trying once more in the hope that this is spurious. Otherwise I would leave it to @Marenz to figure out what is going on |
Yup, your problem now @Marenz |
Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
src/frequenz/sdk/actor/_actor.py
Outdated
except Exception as exc: # pylint: disable=broad-except | ||
if isinstance(exc, RuntimeError) and "no running event loop" in str( | ||
exc | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just a loop.is_closed
check here, instead of string match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just calling asyncio.get_running_eventloop()
will throw exactly the exception we're catching here.
We do it this way also in run_forever
, I just copied it from luca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me that we have a more fundamental problem if this fixes the infinite loop issue. Both the actor and the battery status tracker loops should exit when there is a CancelledError
, so it looks like we are forgetting to cancel at some point, or worse, someone is eating up the CancelledError
in the middle.
This hack will uncover this more fundamental issue, which could come to bite us in other ways, so I would try to find the real root cause for this instead of patching it just to pass the tests.
Also probably not the best idea to hijack this PR to fix the CI, why didn't you create a new PR like last time? |
Because this was easier to test, and well, it's working now.. it wasn't reliably reproducable with the other PR which is how we ended up in this situation in the first place ;)
This is fixing the real root cause.
I didn't write it explicitly, but the exact same thing is also happening in the actor-restart part. The actor stops because of the RuntimeError: Eventloop is closed error makes it try to restart before any chancel exception can be done. |
…t loop Signed-off-by: Mathias L. Baumann <[email protected]>
You could have created another PR with the same commits as this PR for testing. Now is like the original PR got completely lost in the noise, and we are also spamming @florian-wagner-frequenz unnecessarily :P Also discussing via slack, but for the records, what I mean about root cause is that these loops should finish, before the event loop is closed, via a
We should find and fix when the loop is being closed without every task being properly stopped and awaited, instead of just hiding when it happens pretending that nothing is wrong... 😱 |
Reraise the cancel error if it was our task that was cancelled. Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
Nah, he announced that he unsubscribed and gave over ownership to me :) (that is, until you highlighted him again now :P ) But yes, I suppose for future historians this is a less optimal conflation of things that get fixed. |
Previously there was a test which violated type-hints. As we can not keep having the test and type hints on that test, the test itself was rewritten to test a semantically slightly different but similar edge case.
The original test case is of course prevented when using type-hints (i.e not passing
None
to a function that doesn't acceptNone
)