from structio.core import run as _run from structio.core.run import run from structio.core import kernel from structio.core.policies.fifo import FIFOPolicy from structio.core.managers.io.simple import SimpleIOManager from structio.core.managers.signals.sigint import SigIntManager from structio.core.time.clock import DefaultClock from structio.core.syscalls import sleep, suspend from structio.core.context import TaskPool, TaskScope from structio.exceptions import ( Cancelled, TimedOut, ResourceClosed, ResourceBroken, ResourceBusy, WouldBlock, ) from structio.core import task from structio.core.task import Task, TaskState from structio.sync import ( Event, Queue, MemoryChannel, Semaphore, Lock, RLock, ) from structio.abc import Channel, Stream, ReadableChannel, WritableChannel from structio.io import socket from structio.io.socket import AsyncSocket from structio.io.files import ( open_file, wrap_file, aprint, stdout, stderr, stdin, ainput, ) from structio.core.run import current_loop, current_task from structio import thread, parallel from structio.path import Path from structio.signals import set_signal_handler, get_signal_handler from structio.parallel import Process, ProcessLimiter from structio import signals as _signals from structio import util def create_pool() -> TaskPool: """ Creates a new task pool """ return TaskPool() def skip_after(timeout) -> TaskScope: """ Creates a new task scope with the specified timeout. No error is raised when the timeout expires """ return TaskScope(timeout=timeout, silent=True) def with_timeout(timeout) -> TaskScope: """ Creates a new task scope with the specified timeout. TimeoutError is raised when the timeout expires """ return TaskScope(timeout=timeout) def clock(): """ Returns the current clock time of the event loop """ return _run.current_loop().clock.current_time() __all__ = [ "run", "sleep", "create_pool", "clock", "Cancelled", "skip_after", "with_timeout", "Event", "Queue", "MemoryChannel", "Channel", "Stream", "ReadableChannel", "WritableChannel", "Semaphore", "TimedOut", "Task", "TaskState", "TaskScope", "TaskPool", "ResourceClosed", "Lock", "RLock", "thread", "open_file", "wrap_file", "aprint", "stderr", "stdin", "stdout", "ainput", "current_loop", "current_task", "Path", "parallel", "get_signal_handler", "set_signal_handler", "util", "ResourceBusy", "ResourceBroken", "WouldBlock", "Process", "ProcessLimiter", "AsyncSocket", ]