Skip to content

Commit 080502d

Browse files
authored
Merge pull request #1638 from hundeboll/optimize-resource-updates
target: poll needed resources only when activating
2 parents bb8caed + d81eb86 commit 080502d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

labgrid/target.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ def interact(self, msg):
4141
else:
4242
input(msg)
4343

44-
def update_resources(self):
44+
def update_resources(self, resources=None):
4545
"""
4646
Iterate over all relevant resources and deactivate any active but
4747
unavailable resources.
4848
"""
4949
if (monotonic() - self.last_update) < 0.1:
5050
return
5151
self.last_update = monotonic()
52-
for resource in self.resources:
52+
for resource in self.resources if resources is None else resources:
5353
resource.poll()
5454
if not resource.avail and resource.state is BindingState.active:
5555
deactivated = self.deactivate(resource)
@@ -71,7 +71,7 @@ def await_resources(self, resources, timeout=None, avail=True):
7171
timeout (float): optional timeout
7272
avail (bool): optionally wait until the resources are unavailable with avail=False
7373
"""
74-
self.update_resources()
74+
self.update_resources(resources)
7575

7676
waiting = set(r for r in resources if r.avail != avail)
7777
static = set(r for r in waiting if r.get_managed_parent() is None)
@@ -102,7 +102,7 @@ def await_resources(self, resources, timeout=None, avail=True):
102102
filter=waiting
103103
)
104104

105-
self.update_resources()
105+
self.update_resources(resources)
106106

107107
def get_resource(self, cls, *, name=None, wait_avail=True):
108108
"""

0 commit comments

Comments
 (0)