Skip to content

Commit

Permalink
Fix flaky test_subprocess_cluster_does_not_depend_on_logging (dask#8417)
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky authored Dec 18, 2023
1 parent 89183a1 commit 415d4fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
12 changes: 4 additions & 8 deletions distributed/deploy/tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@ async def test_subprocess_cluster_does_not_depend_on_logging():
{"distributed": {"logging": {"distributed": logging.CRITICAL + 1}}}
):
async with SubprocessCluster(
asynchronous=True,
dashboard_address=":0",
scheduler_kwargs={"idle_timeout": "5s"},
worker_kwargs={"death_timeout": "5s"},
) as cluster:
async with Client(cluster, asynchronous=True) as client:
result = await client.submit(lambda x: x + 1, 10)
assert result == 11
asynchronous=True, dashboard_address=":0"
) as cluster, Client(cluster, asynchronous=True) as client:
result = await client.submit(lambda x: x + 1, 10)
assert result == 11


@pytest.mark.skipif(
Expand Down
20 changes: 9 additions & 11 deletions distributed/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,26 +1500,24 @@ def new_config(new_config):


@contextmanager
def new_config_file(c):
def new_config_file(c: dict[str, Any]) -> Iterator[None]:
"""
Temporarily change configuration file to match dictionary *c*.
"""
import yaml

old_file = os.environ.get("DASK_CONFIG")
fd, path = tempfile.mkstemp(prefix="dask-config")
with os.fdopen(fd, "w") as f:
yaml.dump(c, f)
os.environ["DASK_CONFIG"] = path
try:
with os.fdopen(fd, "w") as f:
f.write(yaml.dump(c))
os.environ["DASK_CONFIG"] = path
try:
yield
finally:
if old_file:
os.environ["DASK_CONFIG"] = old_file
else:
del os.environ["DASK_CONFIG"]
yield
finally:
if old_file:
os.environ["DASK_CONFIG"] = old_file
else:
del os.environ["DASK_CONFIG"]
os.remove(path)


Expand Down

0 comments on commit 415d4fa

Please sign in to comment.