##// END OF EJS Templates
add log_errors decorator for on_recv callbacks...
MinRK -
Show More
@@ -25,7 +25,7 b' from zmq.eventloop import ioloop, zmqstream'
25 25 from IPython.config.configurable import LoggingConfigurable
26 26 from IPython.utils.traitlets import Set, Instance, CFloat, Integer
27 27
28 from IPython.parallel.util import asbytes
28 from IPython.parallel.util import asbytes, log_errors
29 29
30 30 class Heart(object):
31 31 """A basic heart object for responding to a HeartMonitor.
@@ -148,6 +148,7 b' class HeartMonitor(LoggingConfigurable):'
148 148 self.hearts.remove(heart)
149 149
150 150
151 @log_errors
151 152 def handle_pong(self, msg):
152 153 "a heart just beat"
153 154 current = asbytes(str(self.lifetime))
@@ -454,6 +454,7 b' class Hub(SessionFactory):'
454 454 #-----------------------------------------------------------------------------
455 455
456 456
457 @util.log_errors
457 458 def dispatch_monitor_traffic(self, msg):
458 459 """all ME and Task queue messages come through here, as well as
459 460 IOPub traffic."""
@@ -473,6 +474,7 b' class Hub(SessionFactory):'
473 474 self.log.error("Invalid monitor topic: %r", switch)
474 475
475 476
477 @util.log_errors
476 478 def dispatch_query(self, msg):
477 479 """Route registration requests and queries from clients."""
478 480 try:
@@ -43,7 +43,7 b' from IPython.config.application import Application'
43 43 from IPython.config.loader import Config
44 44 from IPython.utils.traitlets import Instance, Dict, List, Set, Integer, Enum, CBytes
45 45
46 from IPython.parallel import error
46 from IPython.parallel import error, util
47 47 from IPython.parallel.factory import SessionFactory
48 48 from IPython.parallel.util import connect_logger, local_logger, asbytes
49 49
@@ -240,6 +240,8 b' class TaskScheduler(SessionFactory):'
240 240 # [Un]Registration Handling
241 241 #-----------------------------------------------------------------------
242 242
243
244 @util.log_errors
243 245 def dispatch_notification(self, msg):
244 246 """dispatch register/unregister events."""
245 247 try:
@@ -343,6 +345,9 b' class TaskScheduler(SessionFactory):'
343 345 #-----------------------------------------------------------------------
344 346 # Job Submission
345 347 #-----------------------------------------------------------------------
348
349
350 @util.log_errors
346 351 def dispatch_submission(self, raw_msg):
347 352 """Dispatch job submission to appropriate handlers."""
348 353 # ensure targets up to date:
@@ -560,6 +565,9 b' class TaskScheduler(SessionFactory):'
560 565 #-----------------------------------------------------------------------
561 566 # Result Handling
562 567 #-----------------------------------------------------------------------
568
569
570 @util.log_errors
563 571 def dispatch_result(self, raw_msg):
564 572 """dispatch method for result replies"""
565 573 try:
@@ -39,6 +39,8 b' except:'
39 39 import zmq
40 40 from zmq.log import handlers
41 41
42 from IPython.external.decorator import decorator
43
42 44 # IPython imports
43 45 from IPython.config.application import Application
44 46 from IPython.utils import py3compat
@@ -106,6 +108,19 b' class ReverseDict(dict):'
106 108 # Functions
107 109 #-----------------------------------------------------------------------------
108 110
111 @decorator
112 def log_errors(f, self, *args, **kwargs):
113 """decorator to log unhandled exceptions raised in a method.
114
115 For use wrapping on_recv callbacks, so that exceptions
116 do not cause the stream to be closed.
117 """
118 try:
119 return f(self, *args, **kwargs)
120 except Exception:
121 self.log.error("Uncaught exception in %r" % f, exc_info=True)
122
123
109 124 def asbytes(s):
110 125 """ensure that an object is ascii bytes"""
111 126 if isinstance(s, unicode):
General Comments 0
You need to be logged in to leave comments. Login now