Skip to content

Commit

Permalink
double wait does not work, blocking in signal handler not good, exit …
Browse files Browse the repository at this point in the history
…on do_exit, change to SIGINT, use existing stop to support ctrl+c
  • Loading branch information
sshane committed Jan 22, 2025
1 parent 40c8c66 commit d134c40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 7 additions & 6 deletions selfdrive/pandad/pandad.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,21 @@ def main() -> NoReturn:
# signal pandad to close the relay and exit
def signal_handler(signum, frame):
cloudlog.info(f"Caught signal {signum}, exiting")
if process is not None and process.poll() is None:
process.terminate()
process.wait()
sys.exit(1)
nonlocal do_exit
do_exit = True
if process is not None:
process.send_signal(signal.SIGINT)

process = None
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)

count = 0
do_exit = False
first_run = True
params = Params()
no_internal_panda_count = 0

while True:
while not do_exit:
try:
count += 1
cloudlog.event("pandad.flash_and_connect", count=count)
Expand Down
4 changes: 0 additions & 4 deletions system/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ def manager_thread() -> None:
cloudlog.warning(f"Shutting down manager - {param} set")

if shutdown:
# Signal processes to shut down with a small grace period
for p in managed_processes.values():
p.signal(signal.SIGTERM)
time.sleep(1)
break


Expand Down

0 comments on commit d134c40

Please sign in to comment.