appyter.ext.asyncio package¶
Submodules¶
appyter.ext.asyncio.event_emitter module¶
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.
-
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.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.