comparison testcases.py @ 108:218b8c28549c

Fixed a crash due to SIGCHLD interrupting validator output pipe reads
author Oleg Oshmyan <chortos@inbox.lv>
date Fri, 08 Apr 2011 19:24:51 +0300
parents aa0378ea1f93
children 42c8f5c152a5
comparison
equal deleted inserted replaced
107:6589511f5418 108:218b8c28549c
26 c = time.clock() - c 26 c = time.clock() - c
27 if int(c + .5) == 1: 27 if int(c + .5) == 1:
28 clock = time.clock 28 clock = time.clock
29 else: 29 else:
30 clock = time.time 30 clock = time.time
31
32 class DummySignalIgnorer(object):
33 def __enter__(self): pass
34 def __exit__(self, exc_type, exc_value, traceback): pass
35 signal_ignorer = DummySignalIgnorer()
31 36
32 try: 37 try:
33 from win32 import * 38 from win32 import *
34 except Exception: 39 except Exception:
35 from unix import * 40 from unix import *
268 case.outfile.copy(case.problem.config.ansname) 273 case.outfile.copy(case.problem.config.ansname)
269 try: 274 try:
270 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1) 275 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1)
271 except OSError: 276 except OSError:
272 raise CannotStartValidator(sys.exc_info()[1]) 277 raise CannotStartValidator(sys.exc_info()[1])
273 comment = case.process.communicate()[0].strip() 278 with signal_ignorer:
279 comment = case.process.communicate()[0].strip()
274 match = re.match(r'(?i)(ok|(?:correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment) 280 match = re.match(r'(?i)(ok|(?:correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment)
275 if match: 281 if match:
276 comment = comment[match.end():] 282 comment = comment[match.end():]
277 if not case.problem.config.maxexitcode: 283 if not case.problem.config.maxexitcode:
278 if case.process.returncode: 284 if case.process.returncode: