pyfarm.agent.service module¶
Manager Service¶
Sends and receives information from the master and performs systems level tasks such as log reading, system information gathering, and management of processes.
- class pyfarm.agent.service.Agent[source]¶
Bases: object
Main class associated with getting getting the internals of the agent’s operations up and running including adding or updating itself with the master, starting the periodic task manager, and handling shutdown conditions.
- classmethod agent_api()[source]¶
Return the API url for this agent or None if agent_id has not been set
- classmethod agents_endpoint()[source]¶
Returns the API endpoint for used for updating or creating agents on the master
- should_reannounce()[source]¶
Small method which acts as a trigger for reannounce()
- reannounce()[source]¶
Method which is used to periodically contact the master. This method is generally called as part of a scheduled task.
- system_data(requery_timeoffset=False)[source]¶
Returns a dictionary of data containing information about the agent. This is the information that is also passed along to the master.
- start(shutdown_events=True, http_server=True)[source]¶
Internal code which starts the agent, registers it with the master, and performs the other steps necessary to get things running.
Parameters:
- stop()[source]¶
Internal code which stops the agent. This will terminate any running processes, inform the master of the terminated tasks, update the state of the agent on the master.
- post_shutdown_to_master(stop_reactor=True)[source]¶
This method is called before the reactor shuts down and lets the master know that the agent’s state is now offline
- errback_post_agent_to_master(failure)[source]¶
Called when there’s a failure trying to post the agent to the master. This is often because of some lower level issue but it may be recoverable to we retry the request.
- callback_post_agent_to_master(response)[source]¶
Called when we get a response after POSTing the agent to the master.
- post_agent_to_master()[source]¶
Runs the POST request to contact the master. Running this method multiple times should be considered safe but is generally something that should be avoided.
- callback_post_free_ram(response)[source]¶
Called when we get a response back from the master after POSTing a change for free_ram
- errback_post_free_ram(failure)[source]¶
Error handler which is called if we fail to post a ram update to the master for some reason
- callback_free_ram_changed(change_type, key, new_value, old_value)[source]¶
Callback used to decide and act on changes to the config['ram'] value.
- errback_post_cpu_count_change(failure)[source]¶
Error handler which is called if we fail to post a cpu count update to an existing agent for some reason.
- callback_post_cpu_count_change(response)[source]¶
Called when we received a response from the master after
- pyfarm.agent.service.random() → x in the interval [0, 1).¶