Spaces:
Runtime error
Runtime error
Update execute.py
Browse files- execute.py +3 -2
execute.py
CHANGED
@@ -27,6 +27,7 @@ import sys
|
|
27 |
from io import StringIO
|
28 |
import contextlib
|
29 |
import subprocess
|
|
|
30 |
|
31 |
|
32 |
def check_correctness(check_program, output, timeout, task_id, completion_id):
|
@@ -76,9 +77,9 @@ def unsafe_execute(check_program, output, result, timeout):
|
|
76 |
# Run program.
|
77 |
try:
|
78 |
with time_limit(timeout):
|
79 |
-
with open("
|
80 |
f.write(check_program)
|
81 |
-
p = subprocess.Popen(["python", "./
|
82 |
(stdoutdata, stderrdata) = p.communicate()
|
83 |
exit_code = p.returncode
|
84 |
if stderrdata != '':
|
|
|
27 |
from io import StringIO
|
28 |
import contextlib
|
29 |
import subprocess
|
30 |
+
import threading
|
31 |
|
32 |
|
33 |
def check_correctness(check_program, output, timeout, task_id, completion_id):
|
|
|
77 |
# Run program.
|
78 |
try:
|
79 |
with time_limit(timeout):
|
80 |
+
with open("main_{}.py".format(threading.get_ident()), "w") as f:
|
81 |
f.write(check_program)
|
82 |
+
p = subprocess.Popen(["python", "./main_{}.py".format(threading.get_ident())], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8')
|
83 |
(stdoutdata, stderrdata) = p.communicate()
|
84 |
exit_code = p.returncode
|
85 |
if stderrdata != '':
|