fix: stabilize long-running quote refresh

This commit is contained in:
王鹏
2026-11-09 10:42:08 +08:00
parent b7e0894f4b
commit 5f4df03581
6 changed files with 281 additions and 84 deletions

View File

@@ -410,7 +410,25 @@ def test_quote_refresh_does_not_block_main_window(tmp_path, monkeypatch):
assert not window.quote_monitor.is_refreshing
worker_thread = window.quote_monitor._thread
assert worker_thread is not None
assert worker_thread.isRunning()
assert window.quote_monitor.refresh()
deadline = time.perf_counter() + 2
while window.quote_monitor.is_refreshing and time.perf_counter() < deadline:
app.processEvents()
time.sleep(0.01)
assert not window.quote_monitor.is_refreshing
assert window.quote_monitor._thread is worker_thread
window.close()
deadline = time.perf_counter() + 2
while window._close_pending and time.perf_counter() < deadline:
app.processEvents()
time.sleep(0.01)
assert not window._close_pending
service.close()
app.processEvents()