diff options
author | Prabhu Ramachandran | 2016-08-12 16:57:03 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2016-08-12 16:57:03 +0530 |
commit | 3738c8fefa8ac69508bb6daeee045c1f5ea0cb17 (patch) | |
tree | 5f5a82277e59b1e9c083065171aa6b5b1e59bc52 /yaksh/code_server.py | |
parent | 2b03aeb36fa333ea1644a248c742cf0c1df12a5f (diff) | |
download | online_test-3738c8fefa8ac69508bb6daeee045c1f5ea0cb17.tar.gz online_test-3738c8fefa8ac69508bb6daeee045c1f5ea0cb17.tar.bz2 online_test-3738c8fefa8ac69508bb6daeee045c1f5ea0cb17.zip |
Add test case for code server.
This currently fails when multiple threads ask for a code evaluation at
the same time.
Diffstat (limited to 'yaksh/code_server.py')
-rwxr-xr-x | yaksh/code_server.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/yaksh/code_server.py b/yaksh/code_server.py index 2d8567e..a2cd08a 100755 --- a/yaksh/code_server.py +++ b/yaksh/code_server.py @@ -62,7 +62,7 @@ class CodeServer(object): """Calls relevant EvaluateCode class based on language to check the answer code """ - code_evaluator = create_evaluator_instance(language, + code_evaluator = create_evaluator_instance(language, test_case_type, json_data, in_dir @@ -107,11 +107,13 @@ class ServerPool(object): queue = Queue(maxsize=len(ports)) self.queue = queue servers = [] + self.processes = [] for port in ports: server = CodeServer(port, queue) servers.append(server) p = Process(target=server.run) p.start() + self.processes.append(p) self.servers = servers # Public Protocol ########## @@ -140,6 +142,12 @@ class ServerPool(object): server.register_instance(self) server.serve_forever() + def stop(self): + """Stop all the code server processes. + """ + for proc in self.processes: + proc.terminate() + ############################################################################### def main(args=None): |