pdstools.infinity.internal._resource¶
Classes¶
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
Functions¶
|
Run an async function synchronously. |
|
Mark an |
|
Await the result if it's awaitable, otherwise return it as-is. |
Module Contents¶
- _run_sync(async_fn, *args, **kwargs)¶
Run an async function synchronously.
Uses
anyio.runwhen no event loop is running, and falls back tostart_blocking_portalwhen called from within an existing loop (e.g. Jupyter).
- api_method(func)¶
Mark an
async defresource method for automatic sync wrapping.Methods decorated with
@api_methodshould be defined asasync defand mayawaitany of the_a_get/_a_post/… helpers on the resource.On
AsyncAPIResourcesubclasses the method is left as-is (native coroutine).On
SyncAPIResourcesubclasses the method is automatically replaced by a synchronous wrapper (via__init_subclass__) that executes the coroutine with_run_sync().
- async _maybe_await(result)¶
Await the result if it’s awaitable, otherwise return it as-is.
Useful in mixin methods that call something which is sync on
SyncAPIResource(returns a plain value) but async onAsyncAPIResource(returns a coroutine).
- class SyncAPIResource(client: pdstools.infinity.internal._base_client.SyncAPIClient)¶
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- Parameters:
client (pdstools.infinity.internal._base_client.SyncAPIClient)
- classmethod __init_subclass__(**kwargs)¶
- _get¶
- _post¶
- _patch¶
- _put¶
- _delete¶
- _get_api_list¶
- property _public_fields¶
- property _public_dict¶
- class AsyncAPIResource(client: pdstools.infinity.internal._base_client.AsyncAPIClient)¶
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- Parameters:
client (pdstools.infinity.internal._base_client.AsyncAPIClient)
- _get_api_list¶
- _get¶
- _post¶
- _patch¶
- _put¶
- _delete¶
- property _public_fields¶
- property _public_dict¶