@@ -41,15 +41,16 @@ def interact(self, msg):
41
41
else :
42
42
input (msg )
43
43
44
- def update_resources (self , resources = None ):
44
+ def update_resources (self ):
45
45
"""
46
- Iterate over all relevant resources and deactivate any active but
47
- unavailable resources.
46
+ Iterate over this target's resources, deactivate any active but
47
+ unavailable resources and also deactivate any drivers using them.
48
+ This ensures a consistent binding states for this target.
48
49
"""
49
50
if (monotonic () - self .last_update ) < 0.1 :
50
51
return
51
52
self .last_update = monotonic ()
52
- for resource in self .resources if resources is None else resources :
53
+ for resource in self .resources :
53
54
resource .poll ()
54
55
if not resource .avail and resource .state is BindingState .active :
55
56
deactivated = self .deactivate (resource )
@@ -71,7 +72,7 @@ def await_resources(self, resources, timeout=None, avail=True):
71
72
timeout (float): optional timeout
72
73
avail (bool): optionally wait until the resources are unavailable with avail=False
73
74
"""
74
- self .update_resources (resources )
75
+ self .update_resources ()
75
76
76
77
waiting = set (r for r in resources if r .avail != avail )
77
78
static = set (r for r in waiting if r .get_managed_parent () is None )
@@ -102,7 +103,7 @@ def await_resources(self, resources, timeout=None, avail=True):
102
103
filter = waiting
103
104
)
104
105
105
- self .update_resources (resources )
106
+ self .update_resources ()
106
107
107
108
def get_resource (self , cls , * , name = None , wait_avail = True ):
108
109
"""
0 commit comments