summaryrefslogtreecommitdiff
path: root/yaksh/hook_evaluator.py
diff options
context:
space:
mode:
authormahesh2017-04-04 13:00:41 +0530
committermahesh2017-04-04 13:00:41 +0530
commita9d7b48b6a5a79bf619500463d89f03e8ca1b7bb (patch)
tree0c0696c6d071efb7569e425f46c3df2cbb63f6f2 /yaksh/hook_evaluator.py
parent734ad94d177be8ad400eb6f97e98612ce099e56a (diff)
downloadonline_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.tar.gz
online_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.tar.bz2
online_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.zip
Kills stray processes in code, hook and stdio evaluator
Diffstat (limited to 'yaksh/hook_evaluator.py')
-rw-r--r--yaksh/hook_evaluator.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py
index 0819ec9..b86640c 100644
--- a/yaksh/hook_evaluator.py
+++ b/yaksh/hook_evaluator.py
@@ -7,7 +7,8 @@ import os
from .file_utils import copy_files, delete_files
from .base_evaluator import BaseEvaluator
from .grader import TimeoutException
-
+import signal
+import psutil
class HookEvaluator(BaseEvaluator):
def __init__(self, metadata, test_case_data):
@@ -65,10 +66,12 @@ class HookEvaluator(BaseEvaluator):
check = hook_scope["check_answer"]
success, err, mark_fraction = check(self.user_answer)
except TimeoutException:
+ processes = psutil.Process(os.getpid()).children(recursive=True)
+ for process in processes:
+ process.kill()
raise
except Exception:
msg = traceback.format_exc(limit=0)
err = "Error in Hook code: {0}".format(msg)
del tb
return success, err, mark_fraction
- \ No newline at end of file