Revision 0304f041 ncclient/manager.py

b/ncclient/manager.py
56 56
        return False
57 57

  
58 58
    def __getattr__(self, name):
59
        try:
60
            op = operations.INDEX[name]
61
        except KeyError:
59
        op = operations.INDEX.get(name, None)
60
        if op is None:
62 61
            raise AttributeError
63 62
        else:
64
            reply = op(self.session,
63
            return op(self.session,
65 64
                      async=self._async_mode,
66
                      timeout=self.timeout,
65
                      timeout=self._timeout,
67 66
                      raise_mode=self._raise_mode).request
68
            return op if self._async_mode else reply
69

  
67
    
70 68
    def locked(self, target):
71 69
        """Returns a context manager for the *with* statement.
72 70

  
......
79 77
    def close(self):
80 78
        """Closes the NETCONF session. First does *<close-session>* RPC."""
81 79
        try: # try doing it clean
80
            self._async_mode = False
82 81
            self.close_session()
83 82
        except Exception as e:
84 83
            logger.debug('error doing <close-session> -- %r' % e)
85
        if self._session.connected: # if that didn't work...
84
        if self._session.connected: # if that didn't work, this sure will :)
86 85
            self._session.close()
87 86

  
88 87
    @property

Also available in: Unified diff