appyter.ext.asyncio package

Submodules

appyter.ext.asyncio.event_emitter module

class appyter.ext.asyncio.event_emitter.EventEmitter[source]

Bases: object

Javascript-style event emitter

async clear()[source]
async emit(event, **data)[source]
async flush()[source]
off(event, listener)[source]
on(event)[source]
async remove(event)[source]
async wait(event)[source]

appyter.ext.asyncio.event_loop module

class appyter.ext.asyncio.event_loop.EventLoopThread(loop=None)[source]

Bases: threading.Thread

Keep the event loop running in this thread until stop is called.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

stop()[source]
class appyter.ext.asyncio.event_loop.SharedEventLoopThreadPoolExecutor(*args, loop=None, initializer=None, **kwargs)[source]

Bases: concurrent.futures.thread.ThreadPoolExecutor

This thread pool will initialize each thread with the same event loop.

appyter.ext.asyncio.event_loop.get_event_loop()[source]

Get the same loop in different threads, create the loop if it doesn’t exist

appyter.ext.asyncio.event_loop.new_event_loop()[source]

Construct a new event loop with some custom extensions:

  • a dedicated thread to run the event loop

  • a thread pool executor that sets the event loop in spawned threads

appyter.ext.asyncio.event_loop.with_event_loop()[source]

appyter.ext.asyncio.helpers module

Async helpers to convert anything sync to and from anything async without deadlocks. This requires that you initialize the event loop with the appyter.ext.asyncio.event_loop methods which will run the event loop in a dedicated thread and ensure all sync methods are executed on that dedicated event loop. You only need to use ensure_async or ensure_sync these methods will deal with dispatching to the relevant handlers. It works with already-sync/async, context managers, generators, & functions of these.

async appyter.ext.asyncio.helpers.anext(generator)[source]
async appyter.ext.asyncio.helpers.awaitable_identity(obj)[source]
appyter.ext.asyncio.helpers.ensure_async(obj)[source]
appyter.ext.asyncio.helpers.ensure_async_contextmanager(contextmanager)[source]
appyter.ext.asyncio.helpers.ensure_async_func(func)[source]
appyter.ext.asyncio.helpers.ensure_async_generator(generator)[source]
async appyter.ext.asyncio.helpers.ensure_async_literal(obj)[source]
appyter.ext.asyncio.helpers.ensure_async_wrapper(callable)[source]
appyter.ext.asyncio.helpers.ensure_sync(obj)[source]
appyter.ext.asyncio.helpers.ensure_sync_contextmanager(asynccontextmanager)[source]
appyter.ext.asyncio.helpers.ensure_sync_coro(coro)[source]
appyter.ext.asyncio.helpers.ensure_sync_generator(asyncgenerator)[source]
appyter.ext.asyncio.helpers.ensure_sync_wrapper(callable)[source]
appyter.ext.asyncio.helpers.isasynccontextmanager(obj)[source]
appyter.ext.asyncio.helpers.iscontextmanager(obj)[source]

appyter.ext.asyncio.subprocess module

appyter.ext.asyncio.subprocess.sh(*args, chunk_size=65536, **kwargs)[source]

An opinionated asyncio shell that logs stderr & yields stdout, done Unlike standard create_subprocess_exec: LimitOverrunError should not be possible.

async appyter.ext.asyncio.subprocess.stream_readline_to_queue(stream, queue, chunk_size=65536)[source]

Safely yield lines without running into buffer limit

appyter.ext.asyncio.test_helpers module

appyter.ext.asyncio.test_subprocess module

appyter.ext.asyncio.test_subprocess.test_subprocess()[source]

appyter.ext.asyncio.try_n_times module

async appyter.ext.asyncio.try_n_times.async_try_n_times(n, coro, *args, **kwargs)[source]
appyter.ext.asyncio.try_n_times.try_n_times(n, func, *args, **kwargs)[source]

Module contents