From 60df2f059aa8f1b51dace079607b730885e904c6 Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Mon, 10 Oct 2022 10:21:37 +0200 Subject: [PATCH] Fixed mistake from rebase --- giambio/context.py | 4 ++-- giambio/runtime.py | 6 +++--- giambio/traps.py | 2 +- tests/echo_server.py | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/giambio/context.py b/giambio/context.py index 906be9c..c1812dc 100644 --- a/giambio/context.py +++ b/giambio/context.py @@ -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 diff --git a/giambio/runtime.py b/giambio/runtime.py index eb089e8..58d8ba0 100644 --- a/giambio/runtime.py +++ b/giambio/runtime.py @@ -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 diff --git a/giambio/traps.py b/giambio/traps.py index 706618a..e9cbea4 100644 --- a/giambio/traps.py +++ b/giambio/traps.py @@ -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") diff --git a/tests/echo_server.py b/tests/echo_server.py index 761c1f1..1d69e9d 100644 --- a/tests/echo_server.py +++ b/tests/echo_server.py @@ -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}")