adafruit / adafruit/Adafruit_CircuitPython_asyncio
Exception within a task can cause other tasks to run before the exceptioned-task completes
- Dominant language
- Python
- Stars
- 30
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
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:
```py
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the foo and bar coroutine scenario in the issue and investigate the library-internal exception handler that catches exceptions from tasks. First produce a minimum reproducible example that distinguishes user-handled exceptions from internally caught ones. Done means the expected task ordering and traceback behavior are documented or a focused fix is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100