Skip to content

Commit 529b01d

Browse files
committed
chore: move CancelledError and InvalidStateError to tasks
1 parent c277db5 commit 529b01d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

asyncio/core.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
except:
2525
from .task import TaskQueue, Task
2626

27+
# Depending on the version of CircuitPython, these errors may exist in the build-in C code
28+
# even if _asyncio exists
29+
try:
30+
from _asyncio import CancelledError, InvalidStateError
31+
except:
32+
from .task import CancelledError, InvalidStateError
2733

2834
################################################################################
2935
# Exceptions
3036

3137

32-
class CancelledError(BaseException):
33-
"""Injected into a task when calling `Task.cancel()`"""
34-
35-
pass
36-
37-
3838
class TimeoutError(Exception):
3939
"""Raised when waiting for a task longer than the specified timeout."""
4040

asyncio/task.py

+12
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
from . import core
2222

2323

24+
class CancelledError(BaseException):
25+
"""Injected into a task when calling `Task.cancel()`"""
26+
27+
pass
28+
29+
30+
class InvalidStateError(Exception):
31+
"""Can be raised in situations like setting a result value for a task object that already has a result value set."""
32+
33+
pass
34+
35+
2436
# pairing-heap meld of 2 heaps; O(1)
2537
def ph_meld(h1, h2):
2638
if h1 is None:

0 commit comments

Comments
 (0)