Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a delay when testing tree monitor updates #1187

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions tests/test_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import annotations

import threading
import time

import ipywidgets as ipw
import pytest
Expand Down Expand Up @@ -228,10 +231,28 @@ def update_monitor():
for _ in range(10):
self.model.monitor_counter += 1

if without_flag:
# Skip `_adding_branches` flag check
if without_flag: # skip `_adding_branches` flag check
add_branches = self.tree.trunk._add_branches # store original method
self.tree.trunk._add_branches = self.tree.trunk._add_branches_recursive

def delayed_add_branches_recursive(
node: orm.ProcessNode | None = None,
):
node = node or self.tree.trunk.node
for child in sorted(node.called, key=lambda child: child.ctime):
if isinstance(child, orm.CalcFunctionNode):
continue
if child.pk in self.tree.trunk.pks:
continue
if child.process_label in (
"BandsWorkChain",
"ProjwfcBaseWorkChain",
):
delayed_add_branches_recursive(child)
else:
time.sleep(0.5)
self.tree.trunk._add_branch(child)

self.tree.trunk._add_branches = delayed_add_branches_recursive

# Start monitoring thread to update the tree, which will also
# attempt to add branches to expanded parents
Expand Down
Loading