Skip to content

Commit

Permalink
Merge pull request #55 from imnotjames/feat/53/cancelled-and-invalid-…
Browse files Browse the repository at this point in the history
…state

chore: move CancelledError and InvalidStateError to tasks
  • Loading branch information
dhalbert authored Nov 15, 2023
2 parents da943a7 + 3921b20 commit 45f7149
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@
# Import TaskQueue and Task, preferring built-in C code over Python code
try:
from _asyncio import TaskQueue, Task
except:
except ImportError:
from .task import TaskQueue, Task


################################################################################
# Exceptions


class CancelledError(BaseException):
"""Injected into a task when calling `Task.cancel()`"""
# Depending on the release of CircuitPython these errors may or may not
# exist in the C implementation of `_asyncio`. However, when they
# do exist, they must be preferred over the Python code.
try:
from _asyncio import CancelledError, InvalidStateError
except (ImportError, AttributeError):
class CancelledError(BaseException):
"""Injected into a task when calling `Task.cancel()`"""
pass


pass
class InvalidStateError(Exception):
"""Can be raised in situations like setting a result value for a task object that already has a result value set."""
pass


class TimeoutError(Exception):
Expand Down

0 comments on commit 45f7149

Please sign in to comment.