Skip to content

pywry.utils

Utility functions for async operations.


pywry.utils.async_helpers.run_async

run_async(func: F) -> F

Run an async function synchronously.

Create a new event loop, run the coroutine, and close the loop.

PARAMETER DESCRIPTION
func

The async function to wrap.

TYPE: Callable

RETURNS DESCRIPTION
Callable

A synchronous wrapper function.

pywry.utils.async_helpers.async_task

async_task(func: F) -> F

Mark a function as an async task.

A simple passthrough wrapper for async functions.

PARAMETER DESCRIPTION
func

The async function to wrap.

TYPE: Callable

RETURNS DESCRIPTION
Callable

The wrapped async function.

pywry.utils.async_helpers.run_in_thread

run_in_thread(func: F) -> Callable[..., Any]

Run a function in a new thread.

PARAMETER DESCRIPTION
func

The function to run in a thread.

TYPE: Callable

RETURNS DESCRIPTION
Callable

A wrapper that starts the function in a new thread and returns the thread object.