Skip to content

Commit bd1bb13

Browse files
committed
improved grrs001 timing
1 parent a0e2130 commit bd1bb13

3 files changed

Lines changed: 44 additions & 28 deletions

File tree

components/dash-core-components/tests/integration/graph/test_graph_responsive.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,35 @@
44
import flaky
55

66
from dash import Dash, Input, Output, State, dcc, html
7-
import plotly.graph_objects as go
87

98
from dash.exceptions import PreventUpdate
109
from dash.testing import wait
1110

1211

13-
@pytest.mark.parametrize("responsive", [True, False, None])
14-
@pytest.mark.parametrize("autosize", [True, False, None])
15-
@pytest.mark.parametrize("height", [600, None])
16-
@pytest.mark.parametrize("width", [600, None])
17-
@pytest.mark.parametrize("is_responsive", [True, False, "auto"])
18-
def test_grrs001_graph(dash_dcc, responsive, autosize, height, width, is_responsive):
12+
@pytest.mark.parametrize(
13+
"is_responsive,responsive,autosize,height,width",
14+
[
15+
# is_responsive=True: always responsive regardless of other params
16+
(True, None, None, None, None),
17+
(True, False, False, 600, 600), # still responsive even with fixed dims
18+
# is_responsive=False: never responsive regardless of other params
19+
(False, True, True, None, None), # not responsive even with autosize
20+
(False, None, None, 600, 600),
21+
# is_responsive="auto": behavior depends on other params
22+
("auto", True, True, None, None), # responsive: all conditions met
23+
("auto", True, True, 600, None), # responsive: one dim fixed is ok
24+
("auto", True, False, None, None), # NOT responsive: autosize=False
25+
(
26+
"auto",
27+
False,
28+
True,
29+
None,
30+
None,
31+
), # NOT responsive on resize: config.responsive=False
32+
("auto", None, None, 600, 600), # NOT responsive: both dims fixed
33+
],
34+
)
35+
def test_grrs001_graph(dash_dcc, is_responsive, responsive, autosize, height, width):
1936
app = Dash(__name__, eager_loading=True)
2037

2138
header_style = dict(padding="10px", backgroundColor="yellow", flex="0 0 100px")

tests/background_callback/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ def cleanup_background_processes():
2727
cmdline_str = " ".join(cmdline) if cmdline else ""
2828
if "celery" in cmdline_str and "worker" in cmdline_str:
2929
proc.kill()
30-
proc.wait(timeout=3)
31-
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.TimeoutExpired):
30+
except (psutil.NoSuchProcess, psutil.AccessDenied):
3231
pass
32+
# Don't wait - just kill and move on

tests/background_callback/utils.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,27 @@ def get_background_callback_manager():
6868

6969
def kill(proc_pid):
7070
try:
71-
process = psutil.Process(proc_pid)
72-
children = process.children(recursive=True)
73-
74-
# Kill children first
75-
for proc in children:
76-
try:
77-
proc.kill()
78-
except (psutil.NoSuchProcess, psutil.AccessDenied):
79-
pass
80-
81-
# Kill the main process
71+
# Kill by process group first to get all children
8272
try:
83-
process.kill()
84-
except (psutil.NoSuchProcess, psutil.AccessDenied):
73+
os.killpg(proc_pid, 9) # SIGKILL
74+
except (ProcessLookupError, PermissionError, OSError):
8575
pass
8676

87-
# Also kill by process group to catch any orphans
77+
# Also kill individual processes in case they escaped the group
8878
try:
89-
os.killpg(proc_pid, 9) # SIGKILL
90-
except (ProcessLookupError, PermissionError, OSError):
79+
process = psutil.Process(proc_pid)
80+
children = process.children(recursive=True)
81+
for proc in children:
82+
try:
83+
proc.kill()
84+
except (psutil.NoSuchProcess, psutil.AccessDenied):
85+
pass
86+
process.kill()
87+
except (psutil.NoSuchProcess, psutil.AccessDenied):
9188
pass
9289

93-
# Wait for processes to actually terminate
94-
procs_to_wait = [process] + children
95-
psutil.wait_procs(procs_to_wait, timeout=5)
90+
# Brief wait - don't block too long
91+
time.sleep(0.5)
9692

9793
except psutil.NoSuchProcess:
9894
pass
@@ -153,6 +149,9 @@ def setup_background_callback_app(manager_name, app_name):
153149
os.environ.pop("LONG_CALLBACK_MANAGER")
154150
os.environ.pop("CELERY_BROKER")
155151
os.environ.pop("CELERY_BACKEND")
152+
# Close stderr to prevent blocking on pipe buffer
153+
if worker.stderr:
154+
worker.stderr.close()
156155
kill(worker.pid)
157156
from dash import page_registry
158157

0 commit comments

Comments
 (0)