Skip to content

Commit d173c2a

Browse files
vip: fix a nice interaction between scan and daemonize
* 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.
1 parent e51537e commit d173c2a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

cylc/flow/scripts/validate_install_play.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,19 @@ def get_option_parser() -> COP:
9292

9393
@cli_function(get_option_parser)
9494
def main(parser: COP, options: 'Values', workflow_id: Optional[str] = None):
95-
asyncio.run(run(parser, options, workflow_id))
96-
97-
98-
async def run(parser: COP, options: 'Values', workflow_id: Optional[str]):
9995
"""Run Cylc validate - install - play in sequence."""
96+
# NOTE: We call each of the stages in its own event loop because there is a
97+
# strange interaction whereby the cylc.flow.network.scan coroutine pipe can
98+
# cause sys.exit to hang on the original process post-daemonization
10099
if not workflow_id:
101100
workflow_id = '.'
102101
orig_source = workflow_id
103102
source = get_source_location(workflow_id)
104103
log_subcommand('validate', source)
105-
await cylc_validate(parser, options, str(source))
104+
asyncio.run(cylc_validate(parser, options, str(source)))
106105

107106
log_subcommand('install', source)
108-
_, workflow_id = await cylc_install(options, workflow_id)
107+
_, workflow_id = asyncio.run(cylc_install(options, workflow_id))
109108

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

122121
set_timestamps(LOG, options.log_timestamp)
123122
log_subcommand(*sys.argv[1:])
124-
await cylc_play(options, workflow_id)
123+
asyncio.run(cylc_play(options, workflow_id))

0 commit comments

Comments
 (0)