Spaces:
Sleeping
Sleeping
inoki-giskard
commited on
Commit
·
77c3f2f
1
Parent(s):
e5d2c27
Use return code to detect normal exit
Browse files- run_jobs.py +6 -2
run_jobs.py
CHANGED
@@ -159,10 +159,11 @@ def pop_job_from_pipe():
|
|
159 |
command = prepare_env_and_get_command(*job_info[1])
|
160 |
|
161 |
with open(f"./tmp/{task_id}.log", "a") as log_file:
|
|
|
162 |
p = subprocess.Popen(command, stdout=log_file, stderr=subprocess.STDOUT)
|
163 |
-
while pipe.current:
|
164 |
# Wait for finishing
|
165 |
-
p.wait(timeout=1)
|
166 |
|
167 |
if not pipe.current:
|
168 |
# Job interrupted before finishing
|
@@ -171,6 +172,9 @@ def pop_job_from_pipe():
|
|
171 |
|
172 |
log_file.write(f"\nJob interrupted by admin at {time.asctime()}\n")
|
173 |
|
|
|
|
|
|
|
174 |
pipe.current = None
|
175 |
|
176 |
|
|
|
159 |
command = prepare_env_and_get_command(*job_info[1])
|
160 |
|
161 |
with open(f"./tmp/{task_id}.log", "a") as log_file:
|
162 |
+
return_code = None
|
163 |
p = subprocess.Popen(command, stdout=log_file, stderr=subprocess.STDOUT)
|
164 |
+
while pipe.current and not return_code:
|
165 |
# Wait for finishing
|
166 |
+
return_code = p.wait(timeout=1)
|
167 |
|
168 |
if not pipe.current:
|
169 |
# Job interrupted before finishing
|
|
|
172 |
|
173 |
log_file.write(f"\nJob interrupted by admin at {time.asctime()}\n")
|
174 |
|
175 |
+
if return_code:
|
176 |
+
log_file.write(f"\nJob finished with {return_code} at {time.asctime()}\n")
|
177 |
+
|
178 |
pipe.current = None
|
179 |
|
180 |
|