      gpio_set(GPIO.UBLOX_PWR_EN, False)
      teardown_quectel(diag)
      cloudlog.warning("quectel cleanup done")
      sys.exit(0)
    signal.signal(signal.SIGINT, lambda sig, frame: cleanup(assist_fetch_proc))
    signal.signal(signal.SIGTERM, lambda sig, frame: cleanup(assist_fetch_proc))
  
    # connect to modem
    diag = ModemDiag()
    r = setup_quectel(diag)
    want_assistance = not r
 
</s> remove   def cleanup(proc):
 </s> add   def cleanup(sig, frame): </s> remove   while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
    download_assistance()
    time.sleep(10)
 </s> add   try:
    while not os.path.exists(ASSIST_DATA_FILE) and not event.is_set():
      download_assistance()
      event.wait(timeout=10)
  except KeyboardInterrupt:
    pass
  signal.signal(signal.SIGINT, cleanup)
  signal.signal(signal.SIGTERM, cleanup)
      gpio_set(GPIO.UBLOX_PWR_EN, False)
      teardown_quectel(diag)
      cloudlog.warning("quectel cleanup done")
      sys.exit(0)
  signal.signal(signal.SIGINT, cleanup)
  signal.signal(signal.SIGTERM, cleanup)
  signal.signal(signal.SIGINT, cleanup)
  signal.signal(signal.SIGTERM, cleanup)
  
    # connect to modem
    diag = ModemDiag()
    r = setup_quectel(diag)
    want_assistance = not r
keep keep keep keep replace replace keep keep keep keep keep
 rawgpsd: better download proc cleanup (#29199)

* rawgpsd: better download proc cleanup

* more

* cleanup

---------

Co-authored-by: Comma Device <device@comma.ai> 
system/sensord/rawgps/rawgpsd.py