File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 2121# Import TaskQueue and Task, preferring built-in C code over Python code
2222try :
2323 from _asyncio import TaskQueue , Task
24- except :
24+ except ImportError :
2525 from .task import TaskQueue , Task
2626
27-
2827################################################################################
2928# Exceptions
3029
3130
32- class CancelledError (BaseException ):
33- """Injected into a task when calling `Task.cancel()`"""
31+ # Depending on the release of CircuitPython these errors may or may not
32+ # exist in the C implementation of `_asyncio`. However, when they
33+ # do exist, they must be preferred over the Python code.
34+ try :
35+ from _asyncio import CancelledError , InvalidStateError
36+ except (ImportError , AttributeError ):
37+ class CancelledError (BaseException ):
38+ """Injected into a task when calling `Task.cancel()`"""
39+ pass
40+
3441
35- pass
42+ class InvalidStateError (Exception ):
43+ """Can be raised in situations like setting a result value for a task object that already has a result value set."""
44+ pass
3645
3746
3847class TimeoutError (Exception ):
You can’t perform that action at this time.
0 commit comments