Skip to content

Commit

Permalink
UploadProxy: stop if parent no longer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
olegklimov committed Aug 18, 2024
1 parent c836c34 commit d9774e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions self_hosting_machinery/inference/stream_results.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import re
import psutil
import time
import datetime
import termcolor
Expand Down Expand Up @@ -263,7 +264,12 @@ def _upload_results_loop(upload_q: multiprocessing.Queue, cancelled_q: multiproc
setproctitle.setproctitle("upload_results_loop")
req_session = infserver_session()
exit_flag = False
parent_pid = os.getppid()
while not exit_flag:
if not psutil.pid_exists(parent_pid):
logger.warning("Parent process no longer exists, exiting.")
exit_flag = True
break
try:
upload_dict = upload_q.get(timeout=600)
except queue.Empty as e:
Expand Down

0 comments on commit d9774e5

Please sign in to comment.