MCPcopy Index your code
hub / github.com/pydata/xarray / get_dask_scheduler

Function get_dask_scheduler

xarray/backends/locks.py:137–172  ·  view source on GitHub ↗

Determine the dask scheduler that is being used. None is returned if no dask scheduler is active. See Also -------- dask.base.get_scheduler

(get=None, collection=None)

Source from the content-addressed store, hash-verified

135
136
137def get_dask_scheduler(get=None, collection=None) -> str | None:
138 """Determine the dask scheduler that is being used.
139
140 None is returned if no dask scheduler is active.
141
142 See Also
143 --------
144 dask.base.get_scheduler
145 """
146 try:
147 # Fix for bug caused by dask installation that doesn't involve the toolz library
148 # Issue: 4164
149 import dask
150 from dask.base import get_scheduler
151
152 actual_get = get_scheduler(get, collection)
153 except ImportError:
154 return None
155
156 try:
157 from dask.distributed import Client
158
159 if isinstance(actual_get.__self__, Client):
160 return "distributed"
161 except (ImportError, AttributeError):
162 pass
163
164 try:
165 # As of dask=2.6, dask.multiprocessing requires cloudpickle to be installed
166 # Dependency removed in https://github.com/dask/dask/pull/5511
167 if actual_get is dask.multiprocessing.get:
168 return "multiprocessing"
169 except AttributeError:
170 pass
171
172 return "threaded"
173
174
175def get_write_lock(key: str) -> Lock:

Callers 3

_datatree_to_netcdfFunction · 0.90
_get_netcdf_autocloseFunction · 0.90
get_write_lockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…