Skip to content

Commit

Permalink
Compare subproc queue items better.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Sep 2, 2024
1 parent 0e25d1a commit 8d77c6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
13 changes: 13 additions & 0 deletions cylc/flow/subprocctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ def __str__(self):
'mesg': mesg}
return ret.rstrip()

def equal(self, other: 'SubProcContext') -> bool:
"""Compare my input attributes with those of other.
Ignore timestaemp and result attributes.
"""
return (
self.cmd_key == other.cmd_key and
self.cmd == other.cmd and
self.cmd_kwargs == other.cmd_kwargs and
self.host == other.host
)


class SubFuncContext(SubProcContext):
"""Represent the context of a Python function to run as a subprocess.
Expand Down
22 changes: 14 additions & 8 deletions cylc/flow/subprocpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,23 @@ def put_command(
callback_255=callback_255, callback_255_args=callback_255_args
)
else:
queueit = [
ctx, bad_hosts, callback, callback_args,
callback_255, callback_255_args
]
if (
not any(iq[0].cmd == ctx.cmd for iq in self.queuings) and
not any(ir[1].cmd == ctx.cmd for ir in self.runnings)
not any(
queueit[0].equal(iq[0]) and queueit[1:] == iq[1:]
for iq in self.queuings
) and not any(
queueit[0].equal(ir[1]) and queueit[1:] == ir[2:]
for ir in self.runnings
)
):
# Queue it if not already queued or running.
self.queuings.append(
[
ctx, bad_hosts, callback, callback_args,
callback_255, callback_255_args
]
)
# (Compare all attributes of queued items except for
# ctx results and timestamps).
self.queuings.append(queueit)

@classmethod
def run_command(cls, ctx):
Expand Down

0 comments on commit 8d77c6b

Please sign in to comment.