Skip to content

Commit

Permalink
vip: fix a nice interaction between scan and daemonize
Browse files Browse the repository at this point in the history
* The "cylc vip" command combines three individual coroutines, usually
  run in their own event loops.
* For unknown reasons, the cylc.flow.network.scan.scan coroutine pipe, called
  as part of the the "install" coroutine, interacts with the daemonization
  routine called as part of the "play" coroutine.
* Keeping these event loops separate avoids the conflict.
  • Loading branch information
oliver-sanders committed Feb 21, 2024
1 parent e51537e commit d173c2a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cylc/flow/scripts/validate_install_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@ def get_option_parser() -> COP:

@cli_function(get_option_parser)
def main(parser: COP, options: 'Values', workflow_id: Optional[str] = None):
asyncio.run(run(parser, options, workflow_id))


async def run(parser: COP, options: 'Values', workflow_id: Optional[str]):
"""Run Cylc validate - install - play in sequence."""
# NOTE: We call each of the stages in its own event loop because there is a
# strange interaction whereby the cylc.flow.network.scan coroutine pipe can
# cause sys.exit to hang on the original process post-daemonization
if not workflow_id:
workflow_id = '.'
orig_source = workflow_id
source = get_source_location(workflow_id)
log_subcommand('validate', source)
await cylc_validate(parser, options, str(source))
asyncio.run(cylc_validate(parser, options, str(source)))

log_subcommand('install', source)
_, workflow_id = await cylc_install(options, workflow_id)
_, workflow_id = asyncio.run(cylc_install(options, workflow_id))

cleanup_sysargv(
'play',
Expand All @@ -121,4 +120,4 @@ async def run(parser: COP, options: 'Values', workflow_id: Optional[str]):

set_timestamps(LOG, options.log_timestamp)
log_subcommand(*sys.argv[1:])
await cylc_play(options, workflow_id)
asyncio.run(cylc_play(options, workflow_id))

0 comments on commit d173c2a

Please sign in to comment.