fixed time.time() bug - occasionally keeping cron jobs from starting

instead of time.time() all over the code, there is a
  right_now = int(time.time()) at the beginning which is
  used instead of time.time() (so there aren't different times
  being set at different points of the code's execution)

svn path=/trunk/boinc/; revision=3376
This commit is contained in:
David Anderson 2004-05-13 17:00:52 +00:00
parent 6769f9f1e5
commit 4da64d19a4
1 changed files with 5 additions and 4 deletions

View File

@ -119,6 +119,7 @@ import boinc_path_config
from Boinc import configxml
import sys, os, getopt, time, glob, fcntl, signal, socket
right_now = int(time.time())
verbose = os.isatty(sys.stdout.fileno())
verbose_daemon_run = 0
# how long (in seconds) parent should wait before continuing after a fork.
@ -211,7 +212,7 @@ def ensure_dir(filename):
return
def timestamp(t = None):
return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(t or time.time()))
return time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(t or right_now))
def safe_read_int(filename):
try:
@ -397,10 +398,10 @@ def when_will_task_next_run(task, task_run_state):
def time_to_run_task(task, task_run_state):
return (ignore_timestamps
or (time.time() >= when_will_task_next_run(task,task_run_state)))
or (right_now >= when_will_task_next_run(task,task_run_state)))
def update_task_timestamp(task_run_state):
task_run_state.last_run = time.time()
task_run_state.last_run = right_now
def run_task(task):
'''Fork and exec command without stdout/err redirection'''
@ -571,7 +572,7 @@ def command_status():
when_last_run = float(task_run_state.last_run)
last_run = when_last_run and timestamp(when_last_run) or '?'
when_next_run = when_will_task_next_run(task, lookup_task_run_state(task))
next_run = (when_next_run <=time.time()) and 'NOW' or timestamp(when_next_run)
next_run = (when_next_run <= right_now) and 'NOW' or timestamp(when_next_run)
if is_lock_file_locked(get_task_lock_name(task)):
lu = " LOCKED "
else: