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