From 954b26f64c903638bd2c195b595ad08a832ef1fa Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 9 Mar 2015 17:01:29 +0100 Subject: [PATCH 1/2] RPCError: include the exception args we get from remote Without this, you just got "RCPError: AttributeError", now you get (e.g.): RPCError: AttributeError(b"'Repository' object has no attribute 'segments'",) --- attic/remote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/attic/remote.py b/attic/remote.py index f2a0aed06..3c9f1b305 100644 --- a/attic/remote.py +++ b/attic/remote.py @@ -157,7 +157,7 @@ def fetch_from_cache(args): raise PathNotAllowed(*res) if error == b'ObjectNotFound': raise Repository.ObjectNotFound(res[0], self.location.orig) - raise self.RPCError(error) + raise self.RPCError("%s%r" % (error.decode('ascii'), res)) else: yield res if not waiting_for and not calls: @@ -312,4 +312,4 @@ def get_many(self, keys): def cache_if_remote(repository): if isinstance(repository, RemoteRepository): return RepositoryCache(repository) - return repository \ No newline at end of file + return repository From 3b744d2ee8b80c5a0c818443db23fd36e0ae1162 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 9 Mar 2015 20:45:31 +0100 Subject: [PATCH 2/2] fix Repository._active_txn state when lock upgrade fails --- attic/repository.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/attic/repository.py b/attic/repository.py index eed85dc43..096d494f8 100644 --- a/attic/repository.py +++ b/attic/repository.py @@ -138,7 +138,14 @@ def open_index(self, transaction_id): def prepare_txn(self, transaction_id, do_cleanup=True): self._active_txn = True - self.lock.upgrade() + try: + self.lock.upgrade() + except UpgradableLock.WriteLockFailed: + # if upgrading the lock to exclusive fails, we do not have an + # active transaction. this is important for "serve" mode, where + # the repository instance lives on - even if exceptions happened. + self._active_txn = False + raise if not self.index: self.index = self.open_index(transaction_id) if transaction_id is None: