From ca1e8a157b079e67215256b2b83d879f93d3d927 Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Tue, 18 Oct 2022 17:29:31 +0200 Subject: [PATCH] TaskContext now calls Task.__init__() --- aiosched/context.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/aiosched/context.py b/aiosched/context.py index 56b758e..3edea10 100644 --- a/aiosched/context.py +++ b/aiosched/context.py @@ -28,8 +28,6 @@ class TaskContext(Task): inside the event loop """ - name: str = "" - def __init__(self) -> None: """ Object constructor @@ -39,10 +37,10 @@ class TaskContext(Task): # includes any inner contexts contained within this # one self.tasks: list[Task | "TaskContext"] = [] - self.name = object.__repr__(self) # Whether we have been cancelled or not self.cancelled: bool = False - + super().__init__(f"TaskContext object at {hex(id(self))}", None) + async def spawn( self, func: Callable[..., Coroutine[Any, Any, Any]], *args, **kwargs ) -> Task: @@ -111,4 +109,4 @@ class TaskContext(Task): Implements repr(self) """ - return object.__repr__(self) + return f"TaskContext({self.tasks})"