(client)
| 1091 | |
| 1092 | |
| 1093 | def _ensure_not_async(client): |
| 1094 | if client.asynchronous: |
| 1095 | if fallback := config.get("admin.async-client-fallback", None): |
| 1096 | warnings.warn( |
| 1097 | "Distributed Client detected but Client instance is " |
| 1098 | f"asynchronous. Falling back to `{fallback}` scheduler. " |
| 1099 | "To use an asynchronous Client, please use " |
| 1100 | "``Client.compute`` and ``Client.gather`` " |
| 1101 | "instead of the top level ``dask.compute``", |
| 1102 | UserWarning, |
| 1103 | ) |
| 1104 | return get_scheduler(scheduler=fallback) |
| 1105 | else: |
| 1106 | raise RuntimeError( |
| 1107 | "Attempting to use an asynchronous " |
| 1108 | "Client in a synchronous context of `dask.compute`" |
| 1109 | ) |
| 1110 | return client.get |
| 1111 | |
| 1112 | |
| 1113 | def get_scheduler(get=None, scheduler=None, collections=None, cls=None): |
no test coverage detected