From: Daira Hopwood Date: Thu, 5 Sep 2013 16:59:15 +0000 (+0100) Subject: Wed Apr 4 19:14:09 BST 2012 Brian Warner X-Git-Url: https://git.rkrishnan.org/simplejson/components/%22file:/frontends/webapi.rst?a=commitdiff_plain;h=4b653a652d6d5992f017350eba8233392430ed14;p=tahoe-lafs%2Ftahoe-lafs.git Wed Apr 4 19:14:09 BST 2012 Brian Warner * make IServer instances retain identity in copy() and deepcopy() --- diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 8a78100c..8cd43d7e 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -182,6 +182,15 @@ class NativeStorageServer: self._reconnector = None self._trigger_cb = None + # Special methods used by copy.copy() and copy.deepcopy(). When those are + # used in allmydata.immutable.filenode to copy CheckResults during + # repair, we want it to treat the IServer instances as singletons, and + # not attempt to duplicate them.. + def __copy__(self): + return self + def __deepcopy__(self, memodict): + return self + def __repr__(self): return "" % self.get_name() def get_serverid(self): diff --git a/src/allmydata/test/no_network.py b/src/allmydata/test/no_network.py index ffb6708a..ae294d89 100644 --- a/src/allmydata/test/no_network.py +++ b/src/allmydata/test/no_network.py @@ -26,7 +26,7 @@ from allmydata.storage.server import StorageServer, storage_index_to_dir from allmydata.util import fileutil, idlib, hashutil from allmydata.util.hashutil import sha1 from allmydata.test.common_web import HTTPClientGETFactory -from allmydata.interfaces import IStorageBroker +from allmydata.interfaces import IStorageBroker, IServer from allmydata.test.common import TEST_RSA_KEY_SIZE @@ -122,11 +122,19 @@ def wrap_storage_server(original): return wrapper class NoNetworkServer: + implements(IServer) def __init__(self, serverid, rref): self.serverid = serverid self.rref = rref def __repr__(self): return "" % self.get_name() + # Special method used by copy.copy() and copy.deepcopy(). When those are + # used in allmydata.immutable.filenode to copy CheckResults during + # repair, we want it to treat the IServer instances as singletons. + def __copy__(self): + return self + def __deepcopy__(self, memodict): + return self def get_serverid(self): return self.serverid def get_permutation_seed(self):