mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-27 07:13:59 +00:00
Print thread stack traces on SIGUSR1
This commit is contained in:
parent
9b8cb67d78
commit
7134c0bb05
2 changed files with 20 additions and 0 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
Features:
|
||||
- checking: Support <link rel="dns-prefetch"> URLs.
|
||||
- logging: Sending SIGUSR1 signal prints the stack trace of all current
|
||||
running threads. This makes it easier to debug deadlocks.
|
||||
|
||||
Fixes:
|
||||
- checking: Fix a crash when closing a Word document after scanning failed.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ if _dnspath not in sys.path:
|
|||
sys.path.insert(0, _dnspath)
|
||||
del _dnspath
|
||||
import re
|
||||
import signal
|
||||
import traceback
|
||||
|
||||
from . import i18n
|
||||
import _LinkChecker_configdata as configdata
|
||||
|
|
@ -176,3 +178,19 @@ def find_third_party_modules ():
|
|||
sys.path.append(os.path.join(third_party, "dnspython"))
|
||||
|
||||
find_third_party_modules()
|
||||
|
||||
# install SIGUSR1 handler
|
||||
from .decorators import signal_handler
|
||||
@signal_handler(signal.SIGUSR1)
|
||||
def print_threadstacks(sig, frame):
|
||||
"""Print stack traces of all running threads."""
|
||||
log.warn(LOG_THREAD, "*** STACKTRACE START ***")
|
||||
for threadId, stack in sys._current_frames().items():
|
||||
log.warn(LOG_THREAD, "# ThreadID: %s" % threadId)
|
||||
for filename, lineno, name, line in traceback.extract_stack(stack):
|
||||
log.warn(LOG_THREAD, 'File: "%s", line %d, in %s' % (filename, lineno, name))
|
||||
line = line.strip()
|
||||
if line:
|
||||
log.warn(LOG_THREAD, " %s" % line)
|
||||
log.warn(LOG_THREAD, "*** STACKTRACE END ***")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue