Skip to content

Commit

Permalink
add graceful shutdown on normal exit
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Jan 7, 2024
1 parent 0546647 commit 6d9dc65
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spf/grbl_sdr_collect_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ def prepare_record_entry(ds: DataSnapshot, rx_pos: np.array, tx_pos: np.array):
)


def signal_handler(sig, frame):
logging.info("Ctrl-c issued -> SHUT IT DOWN!")
def shutdown():
global run_collection
run_collection = False
shutdown_radios()
stop_grbl()


def signal_handler(sig, frame):
logging.info("Ctrl-c issued -> SHUT IT DOWN!")
shutdown()


signal.signal(signal.SIGINT, signal_handler)


Expand Down Expand Up @@ -312,6 +316,7 @@ def bounce_grbl(gm):
)
###
read_thread.read_lock.release()
shutdown()
logging.info("Shuttingdown: sending false to threads")
for read_thread in read_threads:
read_thread.run = False
Expand Down

0 comments on commit 6d9dc65

Please sign in to comment.