# Cylc daemonization on macOS

**URL:** <https://cylc.discourse.group/t/cylc-daemonization-on-macos/999>\
**Category:** Cylc Support\
**Created:** [August 6, 2024, 10:40pm UTC](https://cylc.discourse.group/t/cylc-daemonization-on-macos/999 "2024-08-06T22:40:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [August 6, 2024, 10:40pm UTC](https://cylc.discourse.group/t/cylc-daemonization-on-macos/999/1 "2024-08-06T22:40:05Z")

</div>

Thought I’d **ask** a question for a change… Does anyone out there run Cylc on Apple MacOS?

I recently acquired a MacBook and found that Cylc runs fine in `--no-detach` mode, but  
~~aborts~~ drops a traceback in detaching mode during the double-fork daemonization process:

```auto
INFO - Extracting job.sh to /Users/oliver/cylc-run/bug/run10/.service/etc/job.sh
Traceback (most recent call last):
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
    handle._run()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/oliver/cylc/cylc-flow/cylc/flow/scheduler_cli.py", line 420, in scheduler_cli
    daemonize(scheduler)
  File "/Users/oliver/cylc/cylc-flow/cylc/flow/daemonize.py", line 122, in daemonize
    sys.exit(0)
SystemExit: 0

```

I get exactly the same result with the system-installed Python 3.9, homebrew-installed Python 3.12, and conda-installed Python 3.10.

---

<div class="post-metadata">

**Author:** ![elliotfontaine](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/elliotfontaine/32/380_2.png) [@elliotfontaine](https://cylc.discourse.group/u/elliotfontaine)\
**Post date:** [August 7, 2024, 6:30pm UTC](https://cylc.discourse.group/t/cylc-daemonization-on-macos/999/2 "2024-08-07T18:30:28Z")

</div>

Hi.  
I never had this issue. Which version of MacOS are you using? Which version of Cylc?

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [August 7, 2024, 11:16pm UTC](https://cylc.discourse.group/t/cylc-daemonization-on-macos/999/3 "2024-08-07T23:16:32Z")

</div>

macOS Sonoma 14.5

cylc-8.3.3 - same result for various Python versions

Ah-ha, I’ve just discovered it doesn’t happen for cylc-8.2.0. I’ll try to narrow it down now…

[UPDATE 1]

- cylc-8.2.7 with Python 3.11.9 ✅
- cylc-8.3.0 & cylc-8.3.3 with Python 3.11.9 ❎

So it appears to be due to a change in Cylc for version 8.3.

[UPDATE 2]

- for 8.3.x the traceback above appears in the terminal, but actually the workflow runs fine (not sure how I missed this earlier!) … so maybe it’s to do with a change in how we raise exceptions from the scheduler …
- a similar traceback appears in the scheduler log upon ordering a shutdown

```auto
2024-08-08T11:42:36+12:00 INFO - DONE
Traceback (most recent call last):
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
    handle._run()
  File "/Users/oliver/miniforge3/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Users/oliver/cylc/cylc-flow/cylc/flow/scheduler_cli.py", line 445, in scheduler_cli
    sys.exit(ret)
SystemExit: 0

```

[UPDATE 3]

- the amazing `git bisect` found the bad code change in no time …
- I’ll shift this to a GitHub Issue now [sys.exit traceback running 8.3+ on MacOS · Issue #6291 · cylc/cylc-flow · GitHub](https://github.com/cylc/cylc-flow/issues/6291)

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [August 23, 2024, 2:56am UTC](https://cylc.discourse.group/t/cylc-daemonization-on-macos/999/4 "2024-08-23T02:56:01Z")

</div>

Update: This issue is now fixed, for the next Cylc release.

(And for anyone who hits this with the current release note that it isn’t a functional problem, it just looks bad).
