Scrapy, a fast high-level web crawling & scraping framework for Python.
send_catch_log: pass through results from sendRobust
Pablo Hoffmande8990919546
diff --git a/scrapy/tests/test_utils_signal.py b/scrapy/tests/test_utils_signal.pyindex 314ab9454..139d8a632 100644--- a/scrapy/tests/test_utils_signal.py+++ b/scrapy/tests/test_utils_signal.py@@ -18,6 +18,7 @@ class SignalUtilsTest(unittest.TestCase):def test_handler_check(arg):handlers_called.add(test_handler_check)assert arg == 'test'+ return "OK"def log_received(message, level):handlers_called.add(log_received)@@ -27,11 +28,14 @@ class SignalUtilsTest(unittest.TestCase):dispatcher.connect(log_received, signal=log.logmessage_received)dispatcher.connect(test_handler_error, signal=test_signal)dispatcher.connect(test_handler_check, signal=test_signal)- send_catch_log(test_signal, arg='test')+ result = send_catch_log(test_signal, arg='test')assert test_handler_error in handlers_calledassert test_handler_check in handlers_calledassert log_received in handlers_called+ self.assertEqual(result[0][0], test_handler_error)+ self.assert_(isinstance(result[0][1], Exception))+ self.assertEqual(result[1], (test_handler_check, "OK"))dispatcher.disconnect(log_received, signal=log.logmessage_received)dispatcher.disconnect(test_handler_error, signal=test_signal)diff --git a/scrapy/utils/signal.py b/scrapy/utils/signal.pyindex 8c0ca3ae6..eaa649c9e 100644--- a/scrapy/utils/signal.py+++ b/scrapy/utils/signal.py@@ -8,7 +8,9 @@ def send_catch_log(*args, **kwargs):"""Same as dispatcher.robust.sendRobust but logs any exceptions raised bythe signal handlers"""- for receiver, result in sendRobust(*args, **kwargs):- if isinstance(result, Exception):+ 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, result), level=log.ERROR)+ " exception=%r" % (receiver, response), level=log.ERROR)+ return results