summaryrefslogtreecommitdiff
path: root/obnam
diff options
context:
space:
mode:
authorLars Wirzenius <liw@iki.fi>2008-04-26 21:59:44 +0300
committerLars Wirzenius <liw@iki.fi>2008-04-26 21:59:44 +0300
commitd35d1de041b98eafeb4d86f849a534e7f5a61241 (patch)
treeec5970a861a6ba413d4aa8fe13fcb2fed1b1ed27 /obnam
parent8fa6d3bad5522299f824105591f9b262e8de0848 (diff)
downloadobnam-d35d1de041b98eafeb4d86f849a534e7f5a61241.tar.gz
Close store connections at the end of the program.
Diffstat (limited to 'obnam')
-rw-r--r--obnam/backend.py8
-rw-r--r--obnam/store.py10
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.