diff options
author | Lars Wirzenius <liw@iki.fi> | 2008-04-26 21:59:44 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@iki.fi> | 2008-04-26 21:59:44 +0300 |
commit | d35d1de041b98eafeb4d86f849a534e7f5a61241 (patch) | |
tree | ec5970a861a6ba413d4aa8fe13fcb2fed1b1ed27 /obnam | |
parent | 8fa6d3bad5522299f824105591f9b262e8de0848 (diff) | |
download | obnam-d35d1de041b98eafeb4d86f849a534e7f5a61241.tar.gz |
Close store connections at the end of the program.
Diffstat (limited to 'obnam')
-rw-r--r-- | obnam/backend.py | 8 | ||||
-rw-r--r-- | obnam/store.py | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/obnam/backend.py b/obnam/backend.py index 09d029e0..e5d806eb 100644 --- a/obnam/backend.py +++ b/obnam/backend.py @@ -226,6 +226,11 @@ class SftpBackend(Backend): logging.debug("Opening sftp client") self.sftp_client = self.sftp_transport.open_sftp_client() + def close(self): + """Close the connection, if any.""" + if self.sftp_transport: + self.sftp_transport.close() + def sftp_makedirs(self, dirname, mode=0777): """Create dirname, if it doesn't exist, and all its parents, too""" stack = [] @@ -315,6 +320,9 @@ class SftpBackend(Backend): class FileBackend(Backend): + def close(self): + pass + def really_upload_block(self, block_id, block): dir_full = os.path.join(self.path, os.path.dirname(block_id)) if not os.path.isdir(dir_full): diff --git a/obnam/store.py b/obnam/store.py index 905e66f8..4672af1c 100644 --- a/obnam/store.py +++ b/obnam/store.py @@ -36,6 +36,16 @@ class Store: self._context = context self._host = None + def close(self): + """Close connection to the store. + + You must not use this store instance for anything after + closing it. + + """ + + self._context.be.close() + def get_host_block(self): """Return current host block, or None if one is not known. |