本文整理匯總了Python中result.Result.proc_output方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.proc_output方法的具體用法?Python Result.proc_output怎麽用?Python Result.proc_output使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類result.Result
的用法示例。
在下文中一共展示了Result.proc_output方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import proc_output [as 別名]
#.........這裏部分代碼省略.........
if interactive:
try:
return_queue = Queue.Queue()
def interactive_thread(interactor, Q, case_number, process, case_input, case_output, point_value, source_code):
Q.put_nowait(interactor(case_number, process, case_input=case_input, case_output=case_output, point_value=point_value, source_code=source_code))
ithread = threading.Thread(target=interactive_thread, args=(interactive_grader.grade, return_queue, case_number, process, input_data and cStringIO.StringIO(input_data), output_data and cStringIO.StringIO(output_data), point_value, source_code))
ithread.start()
ithread.join(time + 1.0)
if ithread.is_alive():
result.result_flag = Result.TLE
else:
result = return_queue.get_nowait()
if isinstance(result, tuple) or isinstance(result, list):
result, error = result
else:
error = ''
except:
traceback.print_exc()
try:
process.kill()
except: # The process might've already exited
pass
self.packet_manager.internal_error_packet(problem_id + '\n\n' + traceback.format_exc())
return
else:
process.wait()
else:
result.result_flag = Result.AC
if hasattr(process, 'safe_communicate'):
communicate = process.safe_communicate
else:
communicate = partial(safe_communicate, process)
try:
result.proc_output, error = communicate(input_data, outlimit=25165824, errlimit=1048576)
except OutputLimitExceeded as e:
stream, result.proc_output, error = e.args
print>> sys.stderr, 'OLE:', stream
result.result_flag |= Result.OLE
process.kill()
process.wait()
if error:
sys.stderr.write(error)
# Must check here because we might be interrupted mid-execution
# If we don't bail out, we get an IR.
# In Java's case, all the code after this will crash.
if self._terminate_grading:
raise TerminateGrading()
result.max_memory = process.max_memory or 0.0
result.execution_time = process.execution_time or 0.0
result.r_execution_time = process.r_execution_time or 0.0
# C standard checker will crash if not given a string
if result.proc_output is None:
result.proc_output = ''
if interactive:
check = CheckerResult(result.result_flag == Result.AC, result.points)
else:
check = check_func(input_data, result.proc_output, output_data, point_value)
if not isinstance(check, CheckerResult):
check = CheckerResult(check, check and point_value)
if not check.passed:
result.result_flag |= Result.WA