Skip to content
Permalink
Browse files

Use incremental patching in the "om node wait" codepath

Instead of refetching a daemon status on each event.

Also classify wait as an action runnable on any node.
  • Loading branch information...
cvaroqui committed Jul 15, 2019
1 parent 1cf720d commit b049c3782505729c75398f6b259f0b7eb47fafb1
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/node.py
@@ -75,6 +75,7 @@
"get",
"set",
"unset",
"wait",
)
ACTION_ASYNC = {
"freeze": {
@@ -3450,18 +3451,26 @@ def alarm_handler(signum, frame):
signal.signal(signal.SIGALRM, alarm_handler)
signal.alarm(convert_duration(duration))

for msg in self.daemon_events(server):
kind = msg.get("kind")
last_patch_id = 0
for patch in self.daemon_events(server):
kind = patch.get("kind")
if kind == "patch":
try:
if last_patch_id and last_patch_id+1 == patch["id"]:
try:
json_delta.patch(cluster_data, patch["data"])
last_patch_id = patch["id"]
except Exception:
cluster_data = self._daemon_status()
else:
cluster_data = self._daemon_status()
try:
cluster_data["monitor"]
except KeyError:
continue
if match_patch():
break
elif kind == "event":
if match_event(msg):
if match_event(patch):
break

def events(self, server=None):

0 comments on commit b049c37

Please sign in to comment.
You can’t perform that action at this time.