-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add Python 3.12 to CI now that p4p is updated #655
base: main
Are you sure you want to change the base?
Changes from all commits
47a6f45
d15f3b3
db1746f
7633bc3
6368080
ad985e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,9 @@ def _error_and_kill_pending_tasks( | |
unfinished_tasks = { | ||
task | ||
for task in asyncio.all_tasks(loop) | ||
if task.get_coro().__name__ not in _ALLOWED_PYTEST_TASKS and not task.done() | ||
if (coro := task.get_coro()) is not None | ||
and coro.__name__ not in _ALLOWED_PYTEST_TASKS | ||
and not task.done() | ||
} | ||
for task in unfinished_tasks: | ||
task.cancel() | ||
|
@@ -113,15 +115,22 @@ def fail_test_on_unclosed_tasks(request: FixtureRequest): | |
by the end of the test. | ||
""" | ||
|
||
fail_count = request.session.testsfailed | ||
loop = asyncio.get_event_loop() | ||
loop.set_debug(True) | ||
try: | ||
fail_count = request.session.testsfailed | ||
loop = asyncio.get_running_loop() | ||
|
||
loop.set_debug(True) | ||
|
||
request.addfinalizer( | ||
lambda: _error_and_kill_pending_tasks( | ||
loop, request.node.name, request.session.testsfailed == fail_count | ||
request.addfinalizer( | ||
lambda: _error_and_kill_pending_tasks( | ||
loop, request.node.name, request.session.testsfailed == fail_count | ||
) | ||
) | ||
) | ||
# Once https://github.com/bluesky/ophyd-async/issues/683 | ||
# is finished we can remove this try, except. | ||
except RuntimeError as error: | ||
if str(error) != "no running event loop": | ||
raise error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is it worth having a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean by this? except RuntimeError as error:
if str(error) == "no running event loop":
# Explain
pass
else:
raise error ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes exactly that, just a bit more obvious what is intended There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer the current |
||
|
||
|
||
@pytest.fixture(scope="function") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,10 +90,12 @@ async def wait_then_fail(): | |
await asyncio.sleep(0) | ||
set_mock_value(driver.detector_state, adcore.DetectorState.DISCONNECTED) | ||
|
||
await wait_then_fail() | ||
|
||
acquiring = await adcore.start_acquiring_driver_and_ensure_status( | ||
driver, timeout=0.1 | ||
) | ||
await wait_then_fail() | ||
|
||
with pytest.raises(ValueError): | ||
with pytest.raises( | ||
ValueError, match="Final detector state DetectorState.DISCONNECTED" | ||
): | ||
Comment on lines
+98
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be starting setting up |
||
await acquiring |
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.
get_event_loop
gives a deprecation warning that future python versions will raise an error if there is no event loop,get_running_loop
does this already. It doesn't seem possible to check for an event loop without failing/warning if there isn't one, so we just catch the exception for the tests which don't use one.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.
Not ready to merge yet. After changing this fixture to be async (which would use the same event loop as the async test about to be started), I had a bunch more errors. Will tackle tomorrow!
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.
Making this method on both main and this branch causes unfinished tasks to be properly caught, and (the same) tests to fail.
#683
We'll also be able to remove this try catch since the event-loop will have to be open for the async fixture to be running.