Skip to content

Commit

Permalink
chore: move CancelledError and InvalidStateError to tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames committed Nov 11, 2023
1 parent c277db5 commit 529b01d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
except:
from .task import TaskQueue, Task

# Depending on the version of CircuitPython, these errors may exist in the build-in C code
# even if _asyncio exists
try:
from _asyncio import CancelledError, InvalidStateError
except:
from .task import CancelledError, InvalidStateError

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


class CancelledError(BaseException):
"""Injected into a task when calling `Task.cancel()`"""

pass


class TimeoutError(Exception):
"""Raised when waiting for a task longer than the specified timeout."""

Expand Down
12 changes: 12 additions & 0 deletions asyncio/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
from . import core


class CancelledError(BaseException):
"""Injected into a task when calling `Task.cancel()`"""

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


# pairing-heap meld of 2 heaps; O(1)
def ph_meld(h1, h2):
if h1 is None:
Expand Down

0 comments on commit 529b01d

Please sign in to comment.