From d35d1de041b98eafeb4d86f849a534e7f5a61241 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 26 Apr 2008 21:59:44 +0300 Subject: Close store connections at the end of the program. --- obnam/backend.py | 8 ++++++++ obnam/store.py | 10 ++++++++++ 2 files changed, 18 insertions(+) (limited to 'obnam') 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. -- cgit v1.2.1