plumpy.greenback_bridge module#

Async/sync bridge for plumpy, built on greenback.

This module is the sole interface to greenback within the plumpy/aiida ecosystem. All greenback usage should go through these wrappers so that the underlying library remains an implementation detail of plumpy.

async plumpy.greenback_bridge.ensure_portal() None[source]#

Ensure a greenback portal is active on the current asyncio task (no-op if one exists).

plumpy.greenback_bridge.has_portal() bool[source]#

Return True if sync_await() can be called in the current context.

plumpy.greenback_bridge.run_until_complete(loop: AbstractEventLoop, awaitable: Awaitable[_T]) _T[source]#

Run awaitable to completion, even if the event loop is already running.

async plumpy.greenback_bridge.run_with_portal(fn: Callable[[...], _T], *args: Any, **kwargs: Any) _T[source]#

Run sync fn in a greenback portal so it can call sync_await().

plumpy.greenback_bridge.sync_await(awaitable: Awaitable[_T]) _T[source]#

Await awaitable from synchronous code. Requires an active portal.