From: David-Sarah Hopwood Date: Mon, 11 Feb 2013 02:43:36 +0000 (+0000) Subject: openstack_container.py: add shutdown() to avoid unclean reactor errors in tests. X-Git-Url: https://git.rkrishnan.org/uri/architecture.txt?a=commitdiff_plain;h=b20f10ee10e49945b971251b45e4cda6bfa35c5f;p=tahoe-lafs%2Ftahoe-lafs.git openstack_container.py: add shutdown() to avoid unclean reactor errors in tests. Signed-off-by: David-Sarah Hopwood --- diff --git a/src/allmydata/storage/backends/cloud/openstack/openstack_container.py b/src/allmydata/storage/backends/cloud/openstack/openstack_container.py index 7525c279..2da588a8 100644 --- a/src/allmydata/storage/backends/cloud/openstack/openstack_container.py +++ b/src/allmydata/storage/backends/cloud/openstack/openstack_container.py @@ -58,6 +58,7 @@ class AuthenticationClient(object): self._reauth_period = reauth_period self._reactor = override_reactor or reactor self._agent = Agent(self._reactor) + self._delayed = None _assert(provider.startswith("rackspace"), provider=provider) self._authenticate = self._authenticate_to_rackspace @@ -121,7 +122,7 @@ class AuthenticationClient(object): #log.msg("Auth response is %s %s %s" % (storage_url, cdn_management_url, auth_token)) self._auth_info = AuthenticationInfo(storage_url, cdn_management_url, auth_token) - self._reactor.callLater(self._reauth_period, self.get_auth_info_locked, suppress_errors=True) + self._delayed = self._reactor.callLater(self._reauth_period, self.get_auth_info_locked, suppress_errors=True) d.addCallback(_got_response) def _failed(f): self._auth_info = None @@ -131,6 +132,11 @@ class AuthenticationClient(object): d.addErrback(_failed) return d + def shutdown(self): + """Used by unit tests to avoid unclean reactor errors.""" + if self._delayed: + self._delayed.cancel() + class OpenStackContainer(ContainerRetryMixin, ContainerListMixin): implements(IContainer)