Traceback on Ctrl-C
- Ctrl-C will print a traceback of all threads instead of complaining
This commit is contained in:
parent
7b9b7504ad
commit
1d87c63504
|
@ -4,6 +4,7 @@ import sys
|
|||
from binascii import hexlify, unhexlify
|
||||
from multiprocessing import current_process
|
||||
from threading import current_thread, enumerate
|
||||
import traceback
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
from debug import logger
|
||||
|
@ -29,10 +30,20 @@ def convertIntToString(n):
|
|||
else:
|
||||
return unhexlify('0' + a[2:])
|
||||
|
||||
|
||||
def convertStringToInt(s):
|
||||
return int(hexlify(s), 16)
|
||||
|
||||
def allThreadTraceback(frame):
|
||||
id2name = dict([(th.ident, th.name) for th in enumerate()])
|
||||
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):
|
||||
logger.error("Got signal %i in %s/%s", signal, current_process().name, current_thread().name)
|
||||
if current_process().name == "RegExParser":
|
||||
|
@ -46,6 +57,7 @@ def signal_handler(signal, frame):
|
|||
if BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'):
|
||||
shutdown.doCleanShutdown()
|
||||
else:
|
||||
allThreadTraceback(frame)
|
||||
print 'Unfortunately you cannot use Ctrl+C when running the UI because the UI captures the signal.'
|
||||
|
||||
def isHostInPrivateIPRange(host):
|
||||
|
|
Loading…
Reference in New Issue
Block a user