Revision 564bee4f

b/ncclient/transport/ssh.py
59 59
        self._transport = None
60 60
        self._connected = False
61 61
        self._channel = None
62
        self._expecting_close = False
63 62
        self._buffer = StringIO() # for incoming data
64 63
        # parsing-related, see _parse()
65 64
        self._parsing_state = 0
......
130 129
            self._host_keys.load(filename)
131 130

  
132 131
    def close(self):
133
        self._expecting_close = True
134 132
        if self._transport.is_active():
135 133
            self._transport.close()
136 134
        self._connected = False
......
327 325
                            raise SessionCloseError(self._buffer.getvalue(), data)
328 326
                        data = data[n:]
329 327
        except Exception as e:
330
            logger.debug('broke out of main loop')
331
            expecting = self._expecting_close
328
            logger.debug('broke out of main loop, error=%r', e)
332 329
            self.close()
333
            logger.debug('error=%r' % e)
334
            logger.debug('expecting_close=%r' % expecting)
335
            if not (isinstance(e, SessionCloseError) and expecting):
336
                self._dispatch_error(e)
330
            self._dispatch_error(e)
337 331

  
338 332
    @property
339 333
    def transport(self):

Also available in: Unified diff