-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pandad: reset safety mode on exit #32103
Conversation
637a41e
to
1e32418
Compare
This PR has had no activity for 30 days. It will be automatically closed in 7 days if there is no activity. |
This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes. |
selfdrive/pandad/pandad.py
Outdated
# override manager's immediate SystemExit to allow pandad to exit gracefully | ||
def signal_handler(signum, frame): | ||
nonlocal do_exit | ||
do_exit = True | ||
cloudlog.warning(f"caught signal {signum}, exiting") | ||
|
||
do_exit = False | ||
signal.signal(signal.SIGTERM, signal_handler) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When creating a new Python process with multiprocessing.Process
, it inherits the parent's signal handler. For manager, that is to cause a SystemExit
immediately, which SIGKILLs pandad.cc before it has a chance to react to the SIGTERM and close the relay.
openpilot/system/manager/manager.py
Lines 183 to 184 in e8857a6
# SystemExit on sigterm | |
signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(1)) |
6d24edd
to
d49eb66
Compare
edca7b0
to
7388329
Compare
…on do_exit, change to SIGINT, use existing stop to support ctrl+c nope
d134c40
to
c54fe08
Compare
The time between the two pandad stop calls is anywhere between 1 and 2s, so this is already plenty of time to receive the signal and close the relay, no extra sleeps are needed at this time: openpilot/system/manager/manager.py Lines 105 to 110 in cb6eb4f
|
allows for restarting the device while onroad without faulting the car