Passed
Push — master ( 94e82a...688275 )
by Matt
01:28
created

ExceptionThread.run()   A

Complexity

Conditions 3

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 3
nop 1
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