Skip to content

Commit 2be6047

Browse files
committed
Use lock instead of sleep
1 parent f7d5f2c commit 2be6047

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/integration/callbacks/test_wildcards.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
from selenium.webdriver.common.keys import Keys
44
import json
5-
import time
5+
from multiprocessing import Lock
66

77
from dash.testing import wait
88
import dash
@@ -556,6 +556,7 @@ def update_selected_values(values):
556556

557557

558558
def test_cbwc008_running_match(dash_duo):
559+
lock = Lock()
559560
app = dash.Dash()
560561

561562
app.layout = [
@@ -590,21 +591,24 @@ def test_cbwc008_running_match(dash_duo):
590591
prevent_initial_call=True,
591592
)
592593
def on_click(_) -> str:
593-
time.sleep(1)
594-
return "done"
594+
with lock:
595+
return "done"
595596

596597
dash_duo.start_server(app)
597598

598599
for i in range(1, 3):
599-
dash_duo.find_element(f"#buttons button:nth-child({i})").click()
600-
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "running")
601-
# verify all the buttons were disabled.
602-
assert dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
603-
"disabled"
604-
)
605-
assert dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
606-
"disabled"
607-
)
600+
with lock:
601+
dash_duo.find_element(f"#buttons button:nth-child({i})").click()
602+
dash_duo.wait_for_text_to_equal(
603+
f"#buttons button:nth-child({i})", "running"
604+
)
605+
# verify all the buttons were disabled.
606+
assert dash_duo.find_element("#buttons button:nth-child(1)").get_attribute(
607+
"disabled"
608+
)
609+
assert dash_duo.find_element("#buttons button:nth-child(2)").get_attribute(
610+
"disabled"
611+
)
608612

609613
dash_duo.wait_for_text_to_equal(f"#output{i}", "done")
610614
dash_duo.wait_for_text_to_equal(f"#buttons button:nth-child({i})", "finished")

0 commit comments

Comments
 (0)