|
1 | 1 | import signal, sys, threading |
2 | 2 | from . import _maix |
3 | 3 |
|
4 | | -force_exit_timeout = 2 |
| 4 | +# force_exit_timeout = 2 |
5 | 5 |
|
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) |
9 | 9 |
|
10 | 10 | def signal_handle(signum, frame): |
11 | 11 | _maix.app.set_exit_flag(True) |
12 | 12 | signal.signal(signal.SIGINT, signal.SIG_DFL) |
13 | 13 | signal.signal(signal.SIGILL, signal.SIG_DFL) |
14 | 14 | 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() |
20 | 15 |
|
| 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() |
21 | 27 | def register_signal_handle(): |
22 | 28 | signal.signal(signal.SIGINT, signal_handle) |
23 | 29 | signal.signal(signal.SIGILL, signal_handle) |
|
0 commit comments