From 8202f155676291551019d777bdd4867c5b826691 Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Wed, 27 Jul 2022 15:40:33 +0200 Subject: [PATCH 1/4] Make _reconfigure an autouse fixture --- distributed/utils_test.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/distributed/utils_test.py b/distributed/utils_test.py index fadc6002376..40890ebc8f4 100644 --- a/distributed/utils_test.py +++ b/distributed/utils_test.py @@ -697,7 +697,7 @@ def cluster( ws = weakref.WeakSet() enable_proctitle_on_children() - with check_process_leak(check=True), check_instances(), _reconfigure(): + with check_process_leak(check=True), check_instances(): if nanny: _run_worker = run_nanny else: @@ -1878,8 +1878,8 @@ def check_instances(): DequeHandler.clear_all_instances() -@contextmanager -def _reconfigure(): +@pytest.fixture(autouse=True) +def autoconfigure_test(): reset_config() with dask.config.set( @@ -1904,8 +1904,7 @@ def clean(threads=True, instances=True, processes=True): with check_thread_leak() if threads else nullcontext(): with check_process_leak(check=processes): with check_instances() if instances else nullcontext(): - with _reconfigure(): - yield + yield @pytest.fixture From 8fd5f3caf8b3a0f7be3a91e734230e326acd33ca Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Wed, 27 Jul 2022 15:41:10 +0200 Subject: [PATCH 2/4] Naming --- distributed/utils_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributed/utils_test.py b/distributed/utils_test.py index 40890ebc8f4..a4c4aa30946 100644 --- a/distributed/utils_test.py +++ b/distributed/utils_test.py @@ -1879,7 +1879,7 @@ def check_instances(): @pytest.fixture(autouse=True) -def autoconfigure_test(): +def autoconfigure(): reset_config() with dask.config.set( From e39465025e08f953e88cc2c0b475ffabf2fc4c2f Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Wed, 27 Jul 2022 17:02:44 +0200 Subject: [PATCH 3/4] Retain _reconfigure for downstream use --- distributed/utils_test.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/distributed/utils_test.py b/distributed/utils_test.py index a4c4aa30946..0c0de5dd208 100644 --- a/distributed/utils_test.py +++ b/distributed/utils_test.py @@ -697,7 +697,7 @@ def cluster( ws = weakref.WeakSet() enable_proctitle_on_children() - with check_process_leak(check=True), check_instances(): + with check_process_leak(check=True), check_instances(), _reconfigure(): if nanny: _run_worker = run_nanny else: @@ -1878,8 +1878,8 @@ def check_instances(): DequeHandler.clear_all_instances() -@pytest.fixture(autouse=True) -def autoconfigure(): +@contextmanager +def _reconfigure(): reset_config() with dask.config.set( @@ -2495,3 +2495,9 @@ def _bind_port(port): raise TimeoutError(f"Default ports didn't open up in time for {name_of_test}") yield + + +@pytest.fixture(autouse=True) +def autoconfigure(): + with _reconfigure(): + yield From 20dcf92f492107d9f0ac9ddb118722ecb332bbdd Mon Sep 17 00:00:00 2001 From: Hendrik Makait Date: Wed, 27 Jul 2022 17:03:46 +0200 Subject: [PATCH 4/4] Minor --- distributed/utils_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distributed/utils_test.py b/distributed/utils_test.py index 0c0de5dd208..0e9f472fd3e 100644 --- a/distributed/utils_test.py +++ b/distributed/utils_test.py @@ -1904,7 +1904,8 @@ def clean(threads=True, instances=True, processes=True): with check_thread_leak() if threads else nullcontext(): with check_process_leak(check=processes): with check_instances() if instances else nullcontext(): - yield + with _reconfigure(): + yield @pytest.fixture