Skip to content

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

Open
@anecdata

Description

@anecdata

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions