From a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb Mon Sep 17 00:00:00 2001 From: mahesh Date: Tue, 4 Apr 2017 13:00:41 +0530 Subject: Kills stray processes in code, hook and stdio evaluator --- yaksh/stdio_evaluator.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index fa78a68..ec69851 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -2,6 +2,9 @@ from __future__ import unicode_literals # Local imports from .base_evaluator import BaseEvaluator +from .grader import TimeoutException +import os +import signal class StdIOEvaluator(BaseEvaluator): @@ -9,9 +12,13 @@ class StdIOEvaluator(BaseEvaluator): success = False ip = expected_input.replace(",", " ") encoded_input = '{0}\n'.format(ip).encode('utf-8') - user_output_bytes, output_err_bytes = proc.communicate(encoded_input) - user_output = user_output_bytes.decode('utf-8') - output_err = output_err_bytes.decode('utf-8') + try: + user_output_bytes, output_err_bytes = proc.communicate(encoded_input) + user_output = user_output_bytes.decode('utf-8') + output_err = output_err_bytes.decode('utf-8') + except TimeoutException: + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + raise expected_output = expected_output.replace("\r", "") if not expected_input: error_msg = "Expected Output is\n{0} ".\ -- cgit From 4a8f9a117f6a784fe722b8b381368c41be86024a Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 27 Apr 2017 12:51:10 +0530 Subject: made pep8 changes --- yaksh/stdio_evaluator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index ec69851..554d4c5 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,10 +1,10 @@ from __future__ import unicode_literals +import os +import signal # Local imports from .base_evaluator import BaseEvaluator from .grader import TimeoutException -import os -import signal class StdIOEvaluator(BaseEvaluator): -- cgit