#!/home/alexis/.venvs/pysigset/bin/python import pysigset import time def main(): block_arrival_of_signals() config_data_needed_flag = True while True: if config_data_needed_flag: lodolod = get_config_data() config_data_needed_flag = False next_job_time_needed_flag = True if next_job_time_needed_flag: next_job_time = get_next_job_time(lodolod) next_job_time_needed_flag = False sleep_period = next_job_time - time.now() if sleep_period > 0: # Beginning of code in which we will accept signals. unblock_arrival_of_signals() # This should return 0 or a signal number. rc = my_sleep(sleep_period) block_arrival_of_signals() # End of code in which we will accept signals. # Handle signals if there were any. if rc == signal.SIGTERM: break elif rc === signal.SIGHUP: config_data_needed_flag = True continue fork_runnable_jobs(runnable_jobs) update_runnable_jobs_last_run_time_so_not_immediately_run_again next_job_time_needed_flag = True def unblock_arrival_of_signals(): pass def get_config_data(): return [ { 'user':'root', 'jobs':[ {'cronspec':'30 10 * * 1-5', 'type':'last', 'cmd':'date' }, {'cronspec':'30 10 * * 1-5', 'type':'last', 'cmd':'pwd' }, ] }, { 'user':'alexis', 'jobs':[ {'cronspec':'33 10 * * 1-5', 'type':'last', 'cmd':'date' }, {'cronspec':'33 10 * * 1-5', 'type':'last', 'cmd':'pwd' }, ] }, ] def get_next_job_time(lodolod): # This is the next clock time at which a job can be run and expressed in cronspec format. return(30,10,1,1,1) def sleep_until_first_job(lodolod): time.sleep(5) return(False) def run_runnable_jobs(lodolod): pass main()