prefect.client.utilities
Utilities for working with clients.
get_or_create_client(client=None)
Returns provided client, infers a client from context if available, or creates a new client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
-
|
client (PrefectClient
|
an optional client to use |
required |
Returns:
Type | Description |
---|---|
Tuple[PrefectClient, bool]
|
|
Source code in src/prefect/client/utilities.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
inject_client(fn)
Simple helper to provide a context managed client to an asynchronous function.
The decorated function must take a client
kwarg and if a client is passed when
called it will be used instead of creating a new one, but it will not be context
managed as it is assumed that the caller is managing the context.
Source code in src/prefect/client/utilities.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|