outset icon indicating copy to clipboard operation
outset copied to clipboard

`outset` file `on_demand` line 538

Open Theile opened this issue 2 years ago • 4 comments

I have been looking into this solution, and we use it on several customers, thank you very much!

On line 538 of outset (as part of on_demand argument), this is done:

        open(cleanup_trigger, "w").close()
        time.sleep(0.5)
        if os.path.exists(cleanup_trigger):
            cleanup(cleanup_trigger)

I might not now all about python, but to me it looks like you are creating the cleanup_trigger file, and deleting it again. What am I missing?

Theile avatar Dec 30 '21 08:12 Theile

You could run git blame for the time that code was added (although it's probably been a few years at this point) to see what feature it was being delivered alongside (I'm assuming it's on-demand stuff). Do you actually have a code issue or are you just curious? We can't exactly walk you through the entire control flow as it is 600+ lines, but if you clarify what you expect we can discuss it.

arubdesu avatar Dec 30 '21 14:12 arubdesu

I don't have an issue, but to me this looked like a file being created and deleted again, and maybe this was actually not what was needed, or I don't understand these lines of Python. Just close this…

Theile avatar Dec 30 '21 15:12 Theile

Normally I can't interrogate what my fevered mind was thinking six years ago, but luckily we have git blame! https://github.com/chilcote/outset/commit/ffed742a55dff0e3b53282b7f8f520f115520bae is where that was added. And looking at that, it seems that the problem was a race condition where the launch daemon would trigger again before the on demand job had a chance to remove the trigger file. (Launchd runs on a 10s loop iirc).

So this was a (very naive; again, fevered mind and six years ago) way of ensuring the trigger file was removed very early after the on demand job was kicked off.

I suppose it would make more sense to put this at the beginning of the on demand section, or maybe to rethink my life choices that led me to that point 😂. Cheers

chilcote avatar Dec 30 '21 16:12 chilcote

Thank you so much, I really appreciate this explanation.

Happy New Year!!!

Theile avatar Dec 30 '21 17:12 Theile