Skip to content

Commit

Permalink
chore: move errors into core under the import catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames committed Nov 14, 2023
1 parent 3fd6059 commit 3921b20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
14 changes: 11 additions & 3 deletions asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@
except ImportError:
from .task import TaskQueue, Task

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


# 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):
from .task import CancelledError, InvalidStateError
class CancelledError(BaseException):
"""Injected into a task when calling `Task.cancel()`"""
pass

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

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
12 changes: 0 additions & 12 deletions asyncio/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
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 3921b20

Please sign in to comment.