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

PyDMXControl.utils._ExceptionThread   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ExceptionThread.run() 0 10 3
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