pyfarm.agent.entrypoints.utility module

Utility

Small objects and functions which facilitate operations on the main entry point class.

pyfarm.agent.entrypoints.utility.start_daemon_posix(log, chdir, uid, gid)[source]

Runs the agent process via a double fork. This basically a duplicate of Marcechal’s original code with some adjustments:

http://www.jejik.com/articles/2007/02/ a_simple_unix_linux_daemon_in_python/
Source files from his post are here:
http://www.jejik.com/files/examples/daemon.py http://www.jejik.com/files/examples/daemon3x.py
pyfarm.agent.entrypoints.utility.get_system_identifier(systemid, cache_path=None, write_always=False)[source]

Generate a system identifier based on the mac addresses of this system. Each mac address is converted to an integer then XORed together into an integer value no greater than 0xffffffffffff. This maximum value is derived from a mac address which has been maxed out ff:ff:ff:ff:ff:ff.

This value is used to help identify the agent to the master more reliably than by other means alone. In general we only create this value once so even if the mac addresses should change the return value should not.

For reference, this function builds a system identifier in exactly the same way uuid.getnode() does. The main differences are that we can handle multiple addresses and cache the value between invocations.

Parameters:
  • systemid (int) – If provided then use this value directly instead of trying to generate one. This is useful if you want to use a specific value and provide caching at the same time.
  • cache_path (string) – If provided then the value will be retrieved from this location if it exists. If the location does not exist however this function will generate the value and then store it for future use.
Raises:
  • ValueError – Raised if systemid is provided and it’s outside the value range of input (0 to SYSTEMID_MAX)
  • TypeError – Raised if we receive an unexpected type for one of the inputs