plumpy.events module

Event and loop related classes and functions

class plumpy.events.PlumpyEventLoopPolicy[source]

Bases: asyncio.unix_events._UnixDefaultEventLoopPolicy

Custom event policy that always returns the same event loop that is made reentrant by nest_asyncio.

_loop: Optional[asyncio.events.AbstractEventLoop] = None
get_event_loop() → asyncio.events.AbstractEventLoop[source]

Return the patched event loop.

plumpy.events.get_event_loop()

Return an asyncio event loop.

When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop.

If there is no running event loop set, the function will return the result of get_event_loop_policy().get_event_loop() call.

plumpy.events.new_event_loop(*args: Any, **kwargs: Any) → asyncio.events.AbstractEventLoop[source]
plumpy.events.reset_event_loop_policy()None[source]

Reset the event loop policy to the default.

plumpy.events.run_until_complete(future: _asyncio.Future, loop: Optional[asyncio.events.AbstractEventLoop] = None) → Any[source]
plumpy.events.set_event_loop(*args: Any, **kwargs: Any)None[source]
plumpy.events.set_event_loop_policy()None[source]

Enable plumpy’s event loop policy that will make event loop’s reentrant.