Revision 41e2ed46 ncclient/glue.py

b/ncclient/glue.py
46 46
        self._listeners = set() # TODO(?) weakref
47 47
        self._lock = Lock()
48 48
    
49
    def _dispatch_received(self, raw):
49
    def _dispatch_message(self, raw):
50 50
        "TODO: docstring"
51 51
        root = parse_root(raw)
52 52
        with self._lock:
53 53
            listeners = list(self._listeners)
54 54
        for l in listeners:
55
            logger.debug('[dispatching] message to %s' % l)
56
            l.callback(root, raw)
55
            logger.debug('dispatching message to %r' % l)
56
            try:
57
                l.callback(root, raw)
58
            except Exception as e:
59
                logger.warning('[error] %r' % e)
57 60
    
58 61
    def _dispatch_error(self, err):
59 62
        "TODO: docstring"
60 63
        with self._lock:
61 64
            listeners = list(self._listeners)
62 65
        for l in listeners:
63
            logger.debug('[dispatching] error to %s' % l)
64
            l.errback(err)
66
            logger.debug('dispatching error to %r' % l)
67
            try:
68
                l.errback(err)
69
            except Exception as e:
70
                logger.warning('error %r' % e)
65 71
    
66 72
    def add_listener(self, listener):
67 73
        "TODO: docstring"
68
        logger.debug('[installing listener] %r' % listener)
74
        logger.debug('installing listener %r' % listener)
69 75
        with self._lock:
70 76
            self._listeners.add(listener)
71 77
    
72 78
    def remove_listener(self, listener):
73 79
        "TODO: docstring"
74
        logger.debug('[discarding listener] %r' % listener)
80
        logger.debug('discarding listener %r' % listener)
75 81
        with self._lock:
76 82
            self._listeners.discard(listener)
77 83
    
......
86 92
    
87 93
    def send(self, message):
88 94
        "TODO: docstring"
89
        logger.debug('[queueing] %s' % message)
95
        logger.debug('queueing %s' % message)
90 96
        self._q.put(message)
91 97

  
92 98

  

Also available in: Unified diff