summaryrefslogtreecommitdiff
path: root/yaksh/stdio_evaluator.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-27 17:28:44 +0530
committerGitHub2017-04-27 17:28:44 +0530
commita67f8597da19527669b596fab08083a18c7e1fcc (patch)
tree26484d05a23223df13aabb42fe674ce759e09187 /yaksh/stdio_evaluator.py
parentea9e60c47b763515b324aa507da06a1e91c488c6 (diff)
parent4a8f9a117f6a784fe722b8b381368c41be86024a (diff)
downloadonline_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.gz
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.bz2
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.zip
Merge pull request #274 from maheshgudi/kill_stray_processes
Kill stray processes
Diffstat (limited to 'yaksh/stdio_evaluator.py')
-rw-r--r--yaksh/stdio_evaluator.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py
index fa78a68..554d4c5 100644
--- a/yaksh/stdio_evaluator.py
+++ b/yaksh/stdio_evaluator.py
@@ -1,7 +1,10 @@
from __future__ import unicode_literals
+import os
+import signal
# Local imports
from .base_evaluator import BaseEvaluator
+from .grader import TimeoutException
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} ".\