Skip to content

Commit

Permalink
lcbc016 uses lock instead of sleep.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Feb 29, 2024
1 parent 58bd9b8 commit 8e4b4fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
10 changes: 5 additions & 5 deletions tests/integration/long_callback/app_page_cancel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from dash import Dash, Input, Output, dcc, html, page_container, register_page

import time

from tests.integration.long_callback.utils import get_long_callback_manager

long_callback_manager = get_long_callback_manager()
Expand All @@ -23,7 +21,7 @@
page_container,
]
)

app.test_lock = lock = long_callback_manager.test_lock

register_page(
"one",
Expand Down Expand Up @@ -78,7 +76,8 @@ def on_click_no_cancel(_):
interval=300,
)
def on_click1(n_clicks):
time.sleep(2)
with lock:
pass
return f"Click {n_clicks}"


Expand All @@ -97,7 +96,8 @@ def on_click1(n_clicks):
interval=300,
)
def on_click1(n_clicks):
time.sleep(2)
with lock:
pass
return f"Click {n_clicks}"


Expand Down
46 changes: 25 additions & 21 deletions tests/integration/long_callback/test_basic_long_callback016.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import time

import pytest

Expand All @@ -12,32 +11,37 @@
def test_lcbc016_multi_page_cancel(dash_duo, manager):
with setup_long_callback_app(manager, "app_page_cancel") as app:
dash_duo.start_server(app)
dash_duo.find_element("#start1").click()
dash_duo.wait_for_text_to_equal("#progress1", "running")
dash_duo.find_element("#shared_cancel").click()
dash_duo.wait_for_text_to_equal("#progress1", "idle")
time.sleep(2.1)

with app.test_lock:
dash_duo.find_element("#start1").click()
dash_duo.wait_for_text_to_equal("#progress1", "running")
dash_duo.find_element("#shared_cancel").click()
dash_duo.wait_for_text_to_equal("#progress1", "idle")

dash_duo.wait_for_text_to_equal("#output1", "initial")

dash_duo.find_element("#start1").click()
dash_duo.wait_for_text_to_equal("#progress1", "running")
dash_duo.find_element("#cancel1").click()
dash_duo.wait_for_text_to_equal("#progress1", "idle")
time.sleep(2.1)
with app.test_lock:
dash_duo.find_element("#start1").click()
dash_duo.wait_for_text_to_equal("#progress1", "running")
dash_duo.find_element("#cancel1").click()
dash_duo.wait_for_text_to_equal("#progress1", "idle")

dash_duo.wait_for_text_to_equal("#output1", "initial")

dash_duo.server_url = dash_duo.server_url + "/2"

dash_duo.find_element("#start2").click()
dash_duo.wait_for_text_to_equal("#progress2", "running")
dash_duo.find_element("#shared_cancel").click()
dash_duo.wait_for_text_to_equal("#progress2", "idle")
time.sleep(2.1)
with app.test_lock:
dash_duo.find_element("#start2").click()
dash_duo.wait_for_text_to_equal("#progress2", "running")
dash_duo.find_element("#shared_cancel").click()
dash_duo.wait_for_text_to_equal("#progress2", "idle")

dash_duo.wait_for_text_to_equal("#output2", "initial")

dash_duo.find_element("#start2").click()
dash_duo.wait_for_text_to_equal("#progress2", "running")
dash_duo.find_element("#cancel2").click()
dash_duo.wait_for_text_to_equal("#progress2", "idle")
time.sleep(2.1)
with app.test_lock:
dash_duo.find_element("#start2").click()
dash_duo.wait_for_text_to_equal("#progress2", "running")
dash_duo.find_element("#cancel2").click()
dash_duo.wait_for_text_to_equal("#progress2", "idle")

dash_duo.wait_for_text_to_equal("#output2", "initial")

0 comments on commit 8e4b4fe

Please sign in to comment.