Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions SmallPackage/SmallSignals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from .SmallOS import SmallOS
from .SmallTask import SmallTask
from .TaskState import TaskState
from .awaitables import InstructionAwaitable

from .awaitables import (
Expand Down Expand Up @@ -57,7 +56,6 @@ class SmallSignals:

if TYPE_CHECKING:
OS: SmallOS | None
state: TaskState

def __init__(self, OS: SmallOS | None, kwargs: dict[str, Any]) -> None:
"""
Expand Down Expand Up @@ -141,32 +139,17 @@ def acceptSignal(self, sig: int) -> int:
self.handlers(self)
return 0

def sleep(
self, secs: float, state_blob: dict[Any, Any] | None = None
) -> InstructionAwaitable[None]:
"""
Return the awaitable used for cooperative sleeping.

``state_blob`` is preserved for compatibility with the older API style,
where suspension helpers could stash task-local state before yielding.
"""
if state_blob is not None:
self.state.update(state_blob)
def sleep(self, secs: float) -> InstructionAwaitable[None]:
"""Return the awaitable used for cooperative sleeping."""
return sleep_instruction(secs)

def wait_signal(
self, sig: int, state_blob: dict[Any, Any] | None = None
) -> InstructionAwaitable[int]:
def wait_signal(self, sig: int) -> InstructionAwaitable[int]:
"""Return the awaitable used to wait until ``sig`` is delivered."""
if state_blob is not None:
self.state.update(state_blob)
return wait_signal_instruction(sig)

def sigSuspendV2(
self, sig: int, state_blob: dict[Any, Any] | None = None
) -> InstructionAwaitable[int]:
def sigSuspendV2(self, sig: int) -> InstructionAwaitable[int]:
"""Compatibility alias for the older generator-era suspension name."""
return self.wait_signal(sig, state_blob)
return self.wait_signal(sig)

def yield_now(self) -> InstructionAwaitable[None]:
"""Return the awaitable used for an explicit cooperative yield."""
Expand Down
7 changes: 0 additions & 7 deletions SmallPackage/SmallTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from .SmallErrors import PIDError, TaskCancelledError
from .SmallSignals import SmallSignals
from .list_util.linkedList import Node
from .TaskState import TaskState


_MISSING = object()
Expand Down Expand Up @@ -60,7 +59,6 @@ def __init__(self, priority: int, routine: TaskRoutine[T], **kwargs: Any) -> Non
self.isWatcher = False
self.parent = None
self.OS: SmallOS | None = None
self.state = TaskState()
self.children = []
self.name = ""
self.args = ()
Expand Down Expand Up @@ -88,8 +86,6 @@ def __init__(self, priority: int, routine: TaskRoutine[T], **kwargs: Any) -> Non
self._adapter_resume_name: str | None = None
self._adapter_resume_job_id: int | None = None

self.state.update({"return_status": 0}, "system")

SmallSignals.__init__(self, self.OS, kwargs)

if kwargs:
Expand Down Expand Up @@ -220,7 +216,6 @@ def complete(self, result: T | None) -> T | None:
self.isReady = 0
self.isWaiting = 0
self.isSleep = 0
self.state.update({"return_status": 0, "result": result}, "system")
return result

def fail(self, exc: BaseException) -> BaseException:
Expand All @@ -230,7 +225,6 @@ def fail(self, exc: BaseException) -> BaseException:
self.isReady = 0
self.isWaiting = 0
self.isSleep = 0
self.state.update({"return_status": -1, "exception": exc}, "system")
return exc

def cancel(self, message: str = "Task cancelled") -> None:
Expand Down Expand Up @@ -270,7 +264,6 @@ def block(self, reason):
self.isReady = 0
self.isWaiting = 1 if reason in ("signal", "join", "join_all", "adapter") else 0
self.isSleep = 1 if reason == "sleep" else 0
self.state.update({"return_status": 1, "blocked_reason": reason}, "system")

def setID(self, pid: int) -> None:
"""Assign the PID chosen by ``SmallOS`` exactly once."""
Expand Down
95 changes: 0 additions & 95 deletions SmallPackage/TaskState.py

This file was deleted.

46 changes: 0 additions & 46 deletions tests/test_taskState.py

This file was deleted.

Loading