Skip to content
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

Exception within a task can cause other tasks to run before the exceptioned-task completes #36

Open
anecdata opened this issue Dec 17, 2022 · 0 comments

Comments

@anecdata
Copy link
Member

anecdata commented Dec 17, 2022

Placeholder for now, until I can come up with a minimum reproducible example.

Not sure if this belongs here, or in circuitpython.

Occurs in 7.3.3 and 8.0.0-beta.5.

Basic scenario:

async def foo(interval1):
     print("A")
     # some_statement_that_produces_a_caught_exception()
     print("B")
     await asyncio.sleep(interval1)

async def bar(interval2):
     print("C")
     print("D")
     await asyncio.sleep(interval2)

Output:

A
C
D
# traceback.print_exception(None, exc, exc.__traceback__) from library
B (??)

It seems to occur when the exception is caught by the library-internal exception handler, rather than when the exception is caught by user code.

edited to reflect additional testing

So maybe this is intended behavior? It was confusing that the exceptioned-task was interrupted, but the exception wasn't printed until after other tasks had run. I thought I had a case where print("B") would show up later after the library traceback, but now I'm not sure.

Addendum: When the library catches routine development bugs like this (syntax errors, type errors), but everything continues to operate, it can mask problems with the user code.

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

No branches or pull requests

1 participant