Resolved pylint warnings and removed allThreadTraceback() entirely
This commit is contained in:
parent
f2d3b69bf8
commit
c38d250389
|
@ -153,25 +153,13 @@ def _fixSocket():
|
||||||
socket.IPV6_V6ONLY = 27
|
socket.IPV6_V6ONLY = 27
|
||||||
|
|
||||||
|
|
||||||
def allThreadTraceback(frame):
|
def signal_handler(signum, frame):
|
||||||
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
|
"""Single handler for any signal sent to pybitmessage"""
|
||||||
code = []
|
|
||||||
for threadId, stack in sys._current_frames().items():
|
|
||||||
code.append(
|
|
||||||
'\n# Thread: %s(%d)' % (id2name.get(threadId, ''), threadId))
|
|
||||||
for filename, lineno, name, line in traceback.extract_stack(stack):
|
|
||||||
code.append(
|
|
||||||
'File: "%s", line %d, in %s' % (filename, lineno, name))
|
|
||||||
if line:
|
|
||||||
code.append(' %s' % (line.strip()))
|
|
||||||
print('\n'.join(code))
|
|
||||||
|
|
||||||
|
|
||||||
def signal_handler(signal, frame):
|
|
||||||
process = multiprocessing.current_process()
|
process = multiprocessing.current_process()
|
||||||
|
thread = threading.current_thread()
|
||||||
logger.error(
|
logger.error(
|
||||||
'Got signal %i in %s/%s',
|
'Got signal %i in %s/%s',
|
||||||
signal, process.name, threading.current_thread().name
|
signum, process.name, thread.name
|
||||||
)
|
)
|
||||||
if process.name == "RegExParser":
|
if process.name == "RegExParser":
|
||||||
# on Windows this isn't triggered, but it's fine,
|
# on Windows this isn't triggered, but it's fine,
|
||||||
|
@ -179,13 +167,19 @@ def signal_handler(signal, frame):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
if "PoolWorker" in process.name:
|
if "PoolWorker" in process.name:
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
if threading.current_thread().name not in ("PyBitmessage", "MainThread"):
|
if thread.name not in ("PyBitmessage", "MainThread"):
|
||||||
return
|
return
|
||||||
logger.error("Got signal %i", signal)
|
logger.error("Got signal %i", signum)
|
||||||
if shared.thisapp.daemon or not state.enableGUI: # FIXME redundant?
|
# there are possible non-UI variants to run bitmessage which should shutdown
|
||||||
|
# especially test-mode
|
||||||
|
if shared.thisapp.daemon or not state.enableGUI:
|
||||||
shutdown.doCleanShutdown()
|
shutdown.doCleanShutdown()
|
||||||
else:
|
else:
|
||||||
allThreadTraceback(frame)
|
print('# Thread: %s(%d)' % (thread.name, thread.ident))
|
||||||
|
for filename, lineno, name, line in traceback.extract_stack(frame):
|
||||||
|
print('File: "%s", line %d, in %s' % (filename, lineno, name))
|
||||||
|
if line:
|
||||||
|
print(' %s' % line.strip())
|
||||||
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
||||||
' because the UI captures the signal.')
|
' because the UI captures the signal.')
|
||||||
|
|
||||||
|
|
|
@ -109,14 +109,15 @@ def change_translation(newlocale):
|
||||||
|
|
||||||
# TODO: rewrite
|
# TODO: rewrite
|
||||||
def powQueueSize():
|
def powQueueSize():
|
||||||
curWorkerQueue = queues.workerQueue.qsize()
|
"""Returns the size of queues.workerQueue including current unfinished work"""
|
||||||
|
queue_len = queues.workerQueue.qsize()
|
||||||
for thread in threading.enumerate():
|
for thread in threading.enumerate():
|
||||||
try:
|
try:
|
||||||
if thread.name == "singleWorker":
|
if thread.name == "singleWorker":
|
||||||
curWorkerQueue += thread.busy
|
queue_len += thread.busy
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.info('Thread error %s', err)
|
logger.info('Thread error %s', err)
|
||||||
return curWorkerQueue
|
return queue_len
|
||||||
|
|
||||||
|
|
||||||
class MyForm(settingsmixin.SMainWindow):
|
class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
Reference in New Issue
Block a user