Skip to content

Commit 9244428

Browse files
committed
warn about the profiler when used in tests
1 parent 599708e commit 9244428

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

distributed/cli/tests/test_dask_scheduler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,11 @@ def test_version_option():
475475
assert result.exit_code == 0
476476

477477

478+
@pytest.mark.filterwarnings(
479+
"ignore"
480+
":The profiler was enabled in .* running the profiler in tests is not recommended"
481+
":RuntimeWarning"
482+
)
478483
@pytest.mark.slow
479484
def test_idle_timeout():
480485
start = time()
@@ -483,8 +488,8 @@ def test_idle_timeout():
483488
distributed.cli.dask_scheduler.main, ["--idle-timeout", "1s"]
484489
)
485490
stop = time()
486-
assert 1 < stop - start < 10
487491
assert result.exit_code == 0
492+
assert 1 < stop - start < 10
488493

489494

490495
@pytest.mark.slow

distributed/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import inspect
55
import logging
6+
import os
67
import sys
78
import threading
89
import traceback
@@ -356,6 +357,15 @@ def __init__(
356357

357358
if not hasattr(self.io_loop, "profile"):
358359
if dask.config.get("distributed.worker.profile.enabled"):
360+
current_test = os.environ.get("PYTEST_CURRENT_TEST")
361+
if current_test:
362+
warnings.warn(
363+
f"The profiler was enabled in {current_test}."
364+
" running the profiler in tests is not recommended.",
365+
RuntimeWarning,
366+
stacklevel=2,
367+
)
368+
359369
ref = weakref.ref(self.io_loop)
360370

361371
def stop() -> bool:

0 commit comments

Comments
 (0)