Commit 567eeec9 authored by Paul Rich's avatar Paul Rich

Adding config option for sleeptime for componnents

This allows the site to configure the base sleeptime between automatic
checks on a per-component basis.

This removes the argument and relies on the config file.  Nothing was
setting the option prior to this, and this is a more consistient way to
handle this configuration.
parent a8cd74dd
......@@ -52,10 +52,29 @@ def state_file_location():
return os.path.expandvars(get_config_option('statefiles', "location", "/var/spool/cobalt"))
def get_sleeptime(my_name):
'''Return what sleeptime should be for the base level automatic threads loop.
Checks the components section first, then the named component section.
my_name: the string identifier for this component
A floating point time interval in seconds. The default is 0.01 sec.
Any automatic timing value lower than this value will be effectively overridden by this value.
sleeptime = float(get_config_option("components", "sleeptime", 0.01))
comp_sleeptime = get_config_option(my_name, "sleeptime", None)
if comp_sleeptime is not None:
return float(comp_sleeptime)
return sleeptime
def run_component (component_cls, argv=None, register=True, state_name=False,
cls_kwargs={}, extra_getopt='', time_out=10.0,
single_threaded=False, seq_num=0, aug_comp_name=False,
state_name_match_component=False, sleeptime=0.01):
'''Run the specified Cobalt component until recieving signal to terminate.
......@@ -126,6 +145,7 @@ def run_component (component_cls, argv=None, register=True, state_name=False,
Cobalt.Logging.setup_logging(component_cls.implementation, console_timestamp=True)
if daemon:
child_pid = os.fork()
if child_pid != 0:
......@@ -170,6 +190,9 @@ def run_component (component_cls, argv=None, register=True, state_name=False,
certpath = None
capath = None
sleeptime = get_sleeptime(component_cls.implementation)"Component sleep interval set to %s", sleeptime)
if single_threaded:
# sleeptime is not used due to differences in api.
server = BaseXMLRPCServer(location, keyfile=keypath, certfile=certpath,
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment