File: signal.py

package info (click to toggle)
python-scrapy 0.8-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,904 kB
  • ctags: 2,981
  • sloc: python: 15,349; xml: 199; makefile: 68; sql: 64; sh: 34
file content (16 lines) | stat: -rw-r--r-- 611 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Helper functinos for working with signals"""

from scrapy.xlib.pydispatch import dispatcher
from scrapy.xlib.pydispatch.robust import sendRobust
from scrapy import log

def send_catch_log(*args, **kwargs):
    """Same as dispatcher.robust.sendRobust but logs any exceptions raised by
    the signal handlers
    """
    results = sendRobust(*args, **kwargs)
    for receiver, response in results:
        if isinstance(response, Exception):
            log.msg("Exception caught on signal dispatch: receiver=%r, " \
                " exception=%r" % (receiver, response), level=log.ERROR)
    return results