Fixed mistake from rebase

This commit is contained in:
Nocturn9x 2022-10-10 10:21:37 +02:00
parent d408cffa87
commit 60df2f059a
4 changed files with 7 additions and 6 deletions

View File

@ -53,7 +53,7 @@ class TaskManager:
self._proper_init = False
self.enclosed_pool: Optional["giambio.context.TaskManager"] = None
self.raise_on_timeout: bool = raise_on_timeout
self.entry_point: Optional[giambio.Task] = None
self.entry_point: Optional[Task] = None
async def spawn(self, func: Callable[..., Coroutine[Any, Any, Any]], *args, **kwargs) -> "giambio.task.Task":
"""
@ -66,7 +66,7 @@ class TaskManager:
async def __aenter__(self):
"""
Implements the asynchronous context manager interface,
Implements the asynchronous context manager interface
"""
self._proper_init = True

View File

@ -92,7 +92,7 @@ def create_pool():
Creates an async pool
"""
return TaskManager(get_event_loop().current_task)
return TaskManager()
def with_timeout(timeout: int or float):
@ -101,7 +101,7 @@ def with_timeout(timeout: int or float):
"""
assert timeout > 0, "The timeout must be greater than 0"
mgr = TaskManager(get_event_loop().current_task, timeout, True)
mgr = TaskManager(timeout, True)
loop = get_event_loop()
if loop.current_task is loop.entry_point:
loop.current_pool = mgr
@ -117,7 +117,7 @@ def skip_after(timeout: int or float):
"""
assert timeout > 0, "The timeout must be greater than 0"
mgr = TaskManager(get_event_loop().current_task, timeout)
mgr = TaskManager(timeout)
loop = get_event_loop()
if loop.current_task is loop.entry_point:
loop.current_pool = mgr

View File

@ -67,7 +67,7 @@ async def create_task(coro: Callable[[Any, Any], Coroutine[Any, Any, Any]], pool
"\nWhat you wanna do, instead, is this: pool.create_task(your_func, arg1, arg2, ...)"
)
elif inspect.iscoroutinefunction(coro):
return await create_trap("create_task", coro(*args, **kwargs), pool)
return await create_trap("create_task", coro, pool, *args, **kwargs)
else:
raise TypeError("coro must be a coroutine function")

View File

@ -71,4 +71,5 @@ if __name__ == "__main__":
if isinstance(error, KeyboardInterrupt):
logging.info("Ctrl+C detected, exiting")
else:
raise
logging.error(f"Exiting due to a {type(error).__name__}: {error}")