From: Brian Warner Date: Wed, 4 Apr 2012 18:14:09 +0000 (-0700) Subject: make IServer instances retain identity in copy() and deepcopy() X-Git-Url: https://git.rkrishnan.org/simplejson/-?a=commitdiff_plain;h=55973e61e502781c3025b6b08c2bc64564f7c66f;p=tahoe-lafs%2Ftahoe-lafs.git make IServer instances retain identity in copy() and deepcopy() --- diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 763c2a06..6d2a72dd 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -200,6 +200,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 4bac7d1b..82ada097 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 @@ -120,11 +120,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):