diff --git a/structio/__init__.py b/structio/__init__.py index 02f4f8e..ad4c107 100644 --- a/structio/__init__.py +++ b/structio/__init__.py @@ -13,6 +13,7 @@ from structio.sync import Event, Queue, MemoryChannel, Semaphore, Lock, RLock from structio.abc import Channel, Stream, ChannelReader, ChannelWriter from structio import thread from structio.io.files import open_file, wrap_file, aprint, stdout, stderr, stdin, ainput +from structio.core.run import current_loop, current_task def run(func: Callable[[Any, Any], Coroutine[Any, Any, Any]], @@ -119,5 +120,7 @@ __all__ = ["run", "stderr", "stdin", "stdout", - "ainput" + "ainput", + "current_loop", + "current_task" ] diff --git a/structio/core/kernels/fifo.py b/structio/core/kernels/fifo.py index 9b02002..56d8e95 100644 --- a/structio/core/kernels/fifo.py +++ b/structio/core/kernels/fifo.py @@ -138,7 +138,6 @@ class FIFOKernel(BaseKernel): def reschedule(self, task: Task): if task.done(): return - #print(__import__("inspect").stack()[1].function) self.run_queue.append(task) def check_cancelled(self): @@ -344,7 +343,7 @@ class FIFOKernel(BaseKernel): self.current_pool = pool def close_pool(self, pool: TaskPool): - self.current_pool = self.current_pool.outer + self.current_pool = pool.outer def suspend(self): self.current_task.state = TaskState.PAUSED diff --git a/structio/core/run.py b/structio/core/run.py index 56b60e0..b4b6825 100644 --- a/structio/core/run.py +++ b/structio/core/run.py @@ -50,7 +50,6 @@ def run(func: Callable[[Any, Any], Coroutine[Any, Any, Any]], if not issubclass(kernel, BaseKernel): raise TypeError(f"kernel must be a subclass of structio.core.abc.BaseKernel!") - params = [] check = func if isinstance(func, functools.partial): check = func.func @@ -61,7 +60,6 @@ def run(func: Callable[[Any, Any], Coroutine[Any, Any, Any]], ) elif not inspect.iscoroutinefunction(check): raise StructIOException("structio.run() requires an async function as its first argument!") - params.extend(args) new_event_loop(kernel(clock=clock, restrict_ki_to_checkpoints=restrict_ki_to_checkpoints, io_manager=io_manager, signal_managers=signal_managers, tools=tools))