Do not use tempfile in utils_test
@@ -682,19 +682,6 @@ def _close_queue(q):
q._writer.close() # https://bugs.python.org/issue42752
-class _SafeTemporaryDirectory(tempfile.TemporaryDirectory):
- def __exit__(self, exc_type, exc_value, traceback):
- try:
- return super().__exit__(exc_type, exc_value, traceback)
- except (PermissionError, NotADirectoryError):
- # It appears that we either have a process still interacting with
- # the tmpdirs of the workers or that win process are not releasing
- # their lock in time. We are receiving PermissionErrors during
- # teardown
- # See also https://github.com/dask/distributed/pull/5825
- pass
-
-
@contextmanager
def cluster(
nworkers=2,
@@ -736,13 +723,9 @@ def cluster(
q = get_mp_context().Queue()
stack.callback(_close_queue, q)
for _ in range(nworkers):
- tmpdirname = stack.enter_context(
- _SafeTemporaryDirectory(prefix="_dask_test_worker")
- )
kwargs = merge(
{
"nthreads": 1,
- "local_directory": tmpdirname,
"memory_limit": system.MEMORY_LIMIT,
},
worker_kwargs,
@@ -1070,9 +1053,7 @@ def gen_cluster(
def test_func(*outer_args, **kwargs):
async def async_fn():
result = None
- with _SafeTemporaryDirectory() as tmpdir:
- config2 = merge({"temporary-directory": tmpdir}, config)
- with dask.config.set(config2):
+ with dask.config.set(config):
workers = []
s = False
@@ -1177,9 +1158,7 @@ def gen_cluster(
def get_unclosed():
return [c for c in Comm._instances if not c.closed()] + [
- c
- for c in _global_clients.values()
- if c.status != "closed"
+ c for c in _global_clients.values() if c.status != "closed"
]
try:
@@ -1903,6 +1882,7 @@ def _reconfigure():
with dask.config.set(
{
+ "local_directory": tempfile.gettempdir(),
"distributed.comm.timeouts.connect": "5s",
"distributed.admin.tick.interval": "500 ms",
"distributed.worker.profile.enabled": False,
