| 33 | |
| 34 | |
| 35 | def _distributed_available() -> bool: |
| 36 | # Lazy import in get_scheduler can be expensive |
| 37 | global _DistributedClient, _get_distributed_client, _DISTRIBUTED_AVAILABLE |
| 38 | if _DISTRIBUTED_AVAILABLE is not None: |
| 39 | return _DISTRIBUTED_AVAILABLE # type: ignore[unreachable] |
| 40 | try: |
| 41 | from distributed import Client as _DistributedClient |
| 42 | from distributed.worker import get_client as _get_distributed_client |
| 43 | |
| 44 | _DISTRIBUTED_AVAILABLE = True |
| 45 | except ImportError: |
| 46 | _DISTRIBUTED_AVAILABLE = False |
| 47 | return _DISTRIBUTED_AVAILABLE |
| 48 | |
| 49 | |
| 50 | __all__ = ( |