Skip to content

Commit

Permalink
Gracefully exit runner when modeld is not running (close 3GB memory l…
Browse files Browse the repository at this point in the history
…eak)
  • Loading branch information
SippieCup committed Apr 13, 2020
1 parent e196f49 commit d88ab4e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions selfdrive/modeld/runners/keras_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def run_loop(m):
osize = m.outputs[0].shape[1]
print("ready to run keras model %d -> %d" % (isize, osize), file=sys.stderr)
while 1:
# check parent process, if ppid is 1, then modeld is no longer running and the runner should exit.
if os.getppid() == 1:
break
idata = read(isize).reshape((1, isize))
ret = m.predict_on_batch(idata)
write(ret)
Expand Down

0 comments on commit d88ab4e

Please sign in to comment.