DEV Community


Posted on

Python as a daemon?

I have a unique situation where I need to run a daemon that will interact with Salt and Docker, naturally my thought process is Python, however I’m not sure if Python is the best case or something like C or Go is better?

It doesn’t need to be cross platform, strictly is responsible for syncing up our CDN and software repositories


Top comments (4)

dmerand profile image
Donald Merand • Edited

I think small daemons can be written in any language if performance isn't a huge concern. I write little Ruby daemons all the time, to perform monitoring tasks etc. when I can be decently sure my program isn't leaking memory or anything like that.

I'll either run them as periodically-executed Cron scripts, or just make them infinite-looping programs. Both approaches have worked fine for me.

mahmoudhossam profile image
Mahmoud Hossam

You can run your Python program under something like Supervisor or Circus.

michaelgv profile image

True, but it doesn’t answer the fundemential question, of which tecchnology is better for the lightweight daemon

k4ml profile image
Kamal Mustafa

So performance is a concern for you ? Definitely python, depending on what you're doing will take some memory upfront. It easy to take up to 50MB even just for a simple program but at the same time it quite stable. It seldom leak memory (but if it did, quite challenging to troubleshoot). So if by lightweight you mean something that can run in just 1MB or less, definitely not python.

At the same time, all our daemons (processing tasks from database, responding to file system events, processing http webhooks, connecting to tcp socket of external application) are using python with daemontools and it's running fine for years.