[stats] remove signal handling + misc fixes

* signal can only be used in the main thread, leading to an error when StatisticThread is instantiated inside a QThread
* misc fixes on imports and variable names
This commit is contained in:
Yann Lanthony 2017-11-10 18:28:00 +01:00
parent 5fc1d92cc2
commit d190012d1d

View file

@ -1,8 +1,8 @@
from collections import defaultdict
import logging
import psutil
import time
import threading
import signal
def bytes2human(n):
@ -174,7 +174,7 @@ class Statistics:
def fromDict(self, d):
version = d.get('fileVersion', 1.0)
if version != self.fileVersion:
logging.info('Cannot load statistics, version was {} and we only support {}.'.format(version, fileVersion))
logging.info('Cannot load statistics, version was {} and we only support {}.'.format(version, self.fileVersion))
self.computer = {}
self.process = {}
self.times = []
@ -190,7 +190,6 @@ bytesPerGiga = 1024. * 1024. * 1024.
class StatisticsThread(threading.Thread):
def __init__(self, chunk):
threading.Thread.__init__(self)
signal.signal(signal.SIGINT, signal.SIG_IGN) # lambda signal, frame: self.stopRequest())
self.chunk = chunk
self.proc = psutil.Process() # by default current process pid
self.statistics = chunk.statistics