Python Forum

Full Version: Python Daemons & Configs & Communication
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. Not fully sure if this is the right thread section. I'm new to this forum and a beginner. I have a hand full of minor questions, but I didn't want to split it across multiple threads.

What makes a daemon a daemon I understand that they're background processes, but is there really a correct way to make one? Or is a 'while True:' script all it takes?

YAML vs ConfigObj? Pros and Cons?

What are some modern options to comunicating with daemons? I heard of doing it through config. Is there a correct way of doing it or should I just have the daemon check the config file repeatedly with a loop and clear it each time?
If it needs to run all the time, then a while True loop is good enough.
When it comes to config, I find the best types of config are the ones that are easy for real people to understand, instead of ones that are made for computers.  So yaml is acceptable, but not really ideal.  toml is currently my favorite format for this, as it supports nested groupings, without being strict about data types.

When it comes to communicating with a long running process, the main question you should ask yourself is what you want it to do if it restarts.  Should your changes be forgotten, or should whatever change you make be permanent?  Following the direction a major package went is a fine choice.  Web servers (apache, lighttpd, nginx, etc) all pretty much operate only off of config files, and if you want a change to the config to take effect, you need to restart the daemon.  Re-parsing a config file while running seems fishy to me.