Total Complexity | 3 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | * PyDMXControl: A Python 3 module to control DMX using OpenDMX or uDMX. |
||
3 | * Featuring fixture profiles, built-in effects and a web control panel. |
||
4 | * <https://github.com/MattIPv4/PyDMXControl/> |
||
5 | * Copyright (C) 2022 Matt Cowley (MattIPv4) ([email protected]) |
||
6 | """ |
||
7 | |||
8 | from os import kill, getpid |
||
9 | from signal import SIGTERM |
||
10 | from threading import Thread |
||
11 | from traceback import print_exc |
||
12 | |||
13 | |||
14 | class ExceptionThread(Thread): |
||
15 | |||
16 | def run(self): |
||
17 | try: |
||
18 | if self._target: |
||
19 | self._target(*self._args, **self._kwargs) |
||
20 | except BaseException: |
||
21 | # Print the exception and kill the whole process |
||
22 | print_exc() |
||
23 | kill(getpid(), SIGTERM) |
||
24 | finally: |
||
25 | del self._target, self._args, self._kwargs |
||
26 |