File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 21
21
# Import TaskQueue and Task, preferring built-in C code over Python code
22
22
try :
23
23
from _asyncio import TaskQueue , Task
24
- except :
24
+ except ImportError :
25
25
from .task import TaskQueue , Task
26
26
27
-
28
27
################################################################################
29
28
# Exceptions
30
29
31
30
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
+
34
41
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
36
45
37
46
38
47
class TimeoutError (Exception ):
You can’t perform that action at this time.
0 commit comments