[launchd-dev] Launchd and python

Michael McCracken michael.mccracken at gmail.com
Sun Mar 14 19:31:43 PDT 2010


Hi, I just spent some time figuring out how to get a launchd agent
written in python (and using UNIX domain sockets) up and running.

I think this was asked previously on the list, and since it wasn't
straightforward to figure out how to make it work, I decided to write
a post about it and put up some public example code.

My post is here:
http://michael-mccracken.net/2010/03/snakes-on-demand-how-to-write-a-python-launchd-agent/

The example code is on bitbucket here:
http://bitbucket.org/mikemccracken/py-launchd/

I'd be interested to hear comments on how I've implemented it.
In particular:

- I use a socket in /private/tmp/ but saw some comments saying that
that might not be good for long-lived agents (mine won't be, but for
sample code it might be better to use something else?)

- To avoid forcing a restart on first-run, I use system() to unload,
then load the plist when my app starts up. This smells - what happens
if I'm doing this while a second app is talking to a running instance
of this agent? Is there a better way?

Thanks for any comments - I'm interested in updating my public code
with the *right way* once I figure it out :)

Cheers,
-mike


More information about the launchd-dev mailing list