Spaces:
Runtime error
Runtime error
gabeorlanski
commited on
Commit
•
589a6ad
1
Parent(s):
4ac5d46
Update execution.py
Browse files- execution.py +16 -13
execution.py
CHANGED
@@ -44,23 +44,26 @@ def safe_execute(
|
|
44 |
stdout=subprocess.PIPE,
|
45 |
stderr=subprocess.PIPE,
|
46 |
)
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
except Exception as e:
|
59 |
stderr = str(e)
|
60 |
stdout = ""
|
61 |
return_code = -1
|
62 |
-
|
63 |
-
|
64 |
|
65 |
return CommandResult(
|
66 |
return_code=return_code,
|
|
|
44 |
stdout=subprocess.PIPE,
|
45 |
stderr=subprocess.PIPE,
|
46 |
)
|
47 |
+
try:
|
48 |
+
outputs = execution_process.communicate(timeout=timeout)
|
49 |
+
|
50 |
+
stdout, stderr = outputs
|
51 |
+
stdout = stdout.decode('utf-8')
|
52 |
+
stderr = stderr.decode('utf-8')
|
53 |
+
runtime = (datetime.datetime.now() - start_time).total_seconds()
|
54 |
+
return_code = execution_process.returncode
|
55 |
+
except subprocess.TimeoutExpired:
|
56 |
+
timed_out = True
|
57 |
+
runtime = timeout
|
58 |
+
|
59 |
+
finally:
|
60 |
+
execution_process.kill()
|
61 |
except Exception as e:
|
62 |
stderr = str(e)
|
63 |
stdout = ""
|
64 |
return_code = -1
|
65 |
+
runtime = -1
|
66 |
+
timed_out = False
|
67 |
|
68 |
return CommandResult(
|
69 |
return_code=return_code,
|