Skip to content

Commit

Permalink
Back out of one change.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Aug 15, 2024
1 parent 8bdb02b commit 8024093
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions cylc/flow/scheduler_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,21 @@ async def scheduler_cli(
from cylc.flow.daemonize import daemonize
try:
daemonize(scheduler)
except SystemExit:
except SystemExit as exc:

Check warning on line 419 in cylc/flow/scheduler_cli.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scheduler_cli.py#L419

Added line #L419 was not covered by tests
# This is supposed to happen on daemonization, but raising
# SystemExit or calling sys.exit() here results in a traceback
# to the terminal at start-up on macOS.
os._exit(0)
excode: int
if isinstance(exc.code, int):
excode = exc.code

Check warning on line 425 in cylc/flow/scheduler_cli.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scheduler_cli.py#L425

Added line #L425 was not covered by tests
elif isinstance(exc.code, str):
try:
excode = int(exc.code)
except ValueError:
excode = 1

Check warning on line 430 in cylc/flow/scheduler_cli.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scheduler_cli.py#L427-L430

Added lines #L427 - L430 were not covered by tests
else:
excode = 1
os._exit(excode)

Check warning on line 433 in cylc/flow/scheduler_cli.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scheduler_cli.py#L432-L433

Added lines #L432 - L433 were not covered by tests

# setup loggers
_open_logs(
Expand All @@ -443,14 +453,12 @@ async def scheduler_cli(
# NOTE: we must clean up all asyncio / threading stuff before exiting
# NOTE: any threads which include sleep statements could cause
# sys.exit to hang if not shutdown properly
msg = "DONE"
if ret != 0:
msg += f" (exit {ret})"
LOG.info(msg)
LOG.info("DONE")
close_log(LOG)
# Calling sys.exit() here results in a traceback to the LOG for normal
# shutdown on macOS, for a detaching scheduler.
os._exit(0)
# The sys.exit call here results in a traceback to the LOG on normal
# shutdown on macOS for a detaching scheduler, but we can't resort to
# os._exit() in this case - it bypasses needed shutdown processing.
sys.exit(ret)


async def _resume(workflow_id, options):
Expand Down

0 comments on commit 8024093

Please sign in to comment.