Mercurial > ~astiob > upreckon > hgweb
changeset 251:d3a5d1929ad2
Wall-clock time limit is now enforced before handling CPU times on Win32 too
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Sun, 19 Jan 2014 01:21:22 +0000 |
parents | acd70a60bc17 |
children | 756dacca888a |
files | upreckon/unix.py upreckon/win32.py |
diffstat | 2 files changed, 20 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/upreckon/unix.py Sun Jan 19 00:50:27 2014 +0000 +++ b/upreckon/unix.py Sun Jan 19 01:21:22 2014 +0000 @@ -227,19 +227,18 @@ if (case.maxwalltime and case.time_stopped - case.time_started > case.maxwalltime): raise WallTimeLimitExceeded - if new_rusage: + if new_rusage and (case.maxcputime or not case.maxwalltime): time_started = old_rusage.ru_utime + old_rusage.ru_stime + cpustart time_stopped = new_rusage.ru_utime + new_rusage.ru_stime # Yes, this actually happens if time_started > time_stopped: time_started = time_stopped - if case.maxcputime or not case.maxwalltime: - case.time_started = time_started - case.time_stopped = time_stopped - case.time_limit_string = case.cpu_time_limit_string - if (case.maxcputime and - time_stopped - time_started > case.maxcputime): - raise CPUTimeLimitExceeded + case.time_started = time_started + case.time_stopped = time_stopped + case.time_limit_string = case.cpu_time_limit_string + if (case.maxcputime and + time_stopped - time_started > case.maxcputime): + raise CPUTimeLimitExceeded if case.maxmemory: if sys.platform != 'darwin': maxrss = case.maxmemory * 1024
--- a/upreckon/win32.py Sun Jan 19 00:50:27 2014 +0000 +++ b/upreckon/win32.py Sun Jan 19 01:21:22 2014 +0000 @@ -537,21 +537,20 @@ try: times = GetProcessTimes(case.process._handle) except WindowsError: - pass + times = None else: - if case.maxcputime or not case.maxwalltime: - cputime = times.kernel + times.user - case.time_stopped = cputime - case.time_started = 0 - case.time_limit_string = case.cpu_time_limit_string - if case.maxcputime and cputime > case.maxcputime: - raise CPUTimeLimitExceeded - else: - case.time_stopped = times.exit - case.time_started = times.creation - walltime = times.exit - times.creation - if case.maxwalltime and walltime > case.maxwalltime: - raise WallTimeLimitExceeded + case.time_stopped = times.exit + case.time_started = times.creation + if (case.maxwalltime and + case.time_stopped - case.time_started > case.maxwalltime): + raise WallTimeLimitExceeded + if times and (case.maxcputime or not case.maxwalltime): + cputime = times.kernel + times.user + case.time_stopped = cputime + case.time_started = 0 + case.time_limit_string = case.cpu_time_limit_string + if case.maxcputime and cputime > case.maxcputime: + raise CPUTimeLimitExceeded if case.maxcputime and case.process.returncode == 1816: raise CPUTimeLimitExceeded if case.maxmemory and GetProcessMemoryInfo: