Skip to content

Commit 20bdf6e

Browse files
committed
When kill process in VS code of MacOS, shutdown controller
1 parent 633804b commit 20bdf6e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

neopia/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import signal
2020
import atexit
21+
import sys
2122

2223
from neopia.scanner import Scanner
2324
from neopia.mode import Mode
@@ -68,11 +69,11 @@ def parallel(*functions):
6869
def _handle_signal(signal, frame):
6970
Runner.shutdown()
7071
raise SystemExit
71-
72-
signal.signal(signal.SIGINT, _handle_signal)
72+
signal.signal(signal.SIGINT, _handle_signal) # CTRL+C
73+
if sys.platform != "win32":
74+
signal.signal(signal.SIGHUP, _handle_signal) # When kill process in VS code
7375

7476
# It's called for a safe exit by sending initial packet to HW, even a normal exit
7577
def exit_handler():
7678
Runner.shutdown()
77-
7879
atexit.register(exit_handler)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="neopia",
5-
version="0.2.3",
5+
version="0.2.4",
66
author="RoboticsWare",
77
author_email="[email protected]",
88
description="Python library for NEOPIA Neobot",

0 commit comments

Comments
 (0)