Skip to content

Commit fb13ac9

Browse files
committed
* Fix maixcam can not release resource
1 parent e6b49e0 commit fb13ac9

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

maix/__signal_handle__.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import signal, sys, threading
22
from . import _maix
33

4-
force_exit_timeout = 2
4+
# force_exit_timeout = 2
55

6-
def force_exit():
7-
print("Force exit now")
8-
sys.exit(1)
6+
# def force_exit():
7+
# print("Force exit now")
8+
# sys.exit(1)
99

1010
def signal_handle(signum, frame):
1111
_maix.app.set_exit_flag(True)
1212
signal.signal(signal.SIGINT, signal.SIG_DFL)
1313
signal.signal(signal.SIGILL, signal.SIG_DFL)
1414
signal.signal(signal.SIGABRT, signal.SIG_DFL)
15-
# set exit flag and wait force_exit_timeout seconds, then force exit
16-
t = threading.Timer(force_exit_timeout, force_exit)
17-
t.daemon = True
18-
t.start()
19-
_maix.util.do_exit_function()
2015

16+
device_name = _maix.sys.device_name().lower()
17+
if device_name == 'maixcam' or device_name == 'maixcam-pro': # MaixCAM must exit at here, otherwise it can not release hardware resources
18+
_maix.util.do_exit_function()
19+
sys.exit(0)
20+
else:
21+
_maix.util.do_exit_function()
22+
sys.exit(0)
23+
# # set exit flag and wait force_exit_timeout seconds, then force exit
24+
# t = threading.Timer(force_exit_timeout, force_exit)
25+
# t.daemon = True
26+
# t.start()
2127
def register_signal_handle():
2228
signal.signal(signal.SIGINT, signal_handle)
2329
signal.signal(signal.SIGILL, signal_handle)

0 commit comments

Comments
 (0)