mirror of https://github.com/scrapy/scrapy.git
stack trace dump extension: also dump engine status, and support triggering it with SIGQUIT, besides SIGUSR2
This commit is contained in:
parent
6069b0e5b2
commit
d72d3f4607
|
|
@ -357,15 +357,25 @@ Stack trace dump extension
|
|||
|
||||
.. class:: scrapy.contrib.debug.StackTraceDump
|
||||
|
||||
Dumps the stack trace of a runnning Scrapy process when a `SIGUSR2`_ signal is
|
||||
received. After the stack trace is dumped, the Scrapy process continues running
|
||||
normally.
|
||||
Dumps the stack trace and Scrapy engine status of a runnning process when a
|
||||
`SIGQUIT`_ or `SIGUSR2`_ signal is received. After the stack trace and engine
|
||||
status is dumped, the Scrapy process continues running normally.
|
||||
|
||||
The stack trace is sent to standard output.
|
||||
The dump is sent to standard output.
|
||||
|
||||
This extension only works on POSIX-compliant platforms (ie. not Windows).
|
||||
|
||||
There are at least two ways to send Scrapy the `SIGQUIT`_ signal:
|
||||
|
||||
1. By pressing Ctrl-\ while a Scrapy process is running (Linux only?)
|
||||
|
||||
2. By running this command (assuming ``<pid>`` is the process id of the Scrapy
|
||||
process)::
|
||||
|
||||
kill -QUIT <pid>
|
||||
|
||||
.. _SIGUSR2: http://en.wikipedia.org/wiki/SIGUSR1_and_SIGUSR2
|
||||
.. _SIGQUIT: http://en.wikipedia.org/wiki/SIGQUIT
|
||||
|
||||
Debugger extension
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -8,18 +8,21 @@ import signal
|
|||
import traceback
|
||||
from pdb import Pdb
|
||||
|
||||
from scrapy.utils.engine import print_engine_status
|
||||
|
||||
|
||||
class StackTraceDump(object):
|
||||
def __init__(self):
|
||||
try:
|
||||
signal.signal(signal.SIGUSR2, self.dump_stacktrace)
|
||||
signal.signal(signal.SIGQUIT, self.dump_stacktrace)
|
||||
except AttributeError:
|
||||
# win32 platforms don't support SIGUSR signals
|
||||
pass
|
||||
|
||||
def dump_stacktrace(self, signum, frame):
|
||||
print "Got signal. Dumping stack trace..."
|
||||
traceback.print_stack(frame)
|
||||
print_engine_status()
|
||||
|
||||
|
||||
class Debugger(object):
|
||||
|
|
|
|||
Loading…
Reference in New Issue