From 78d128f879addb0ee03e680845d54ae1908df9fa Mon Sep 17 00:00:00 2001 From: David-Sarah Hopwood Date: Mon, 11 Feb 2013 02:43:36 +0000 Subject: [PATCH] openstack_container.py: add shutdown() to avoid unclean reactor errors in tests. Signed-off-by: David-Sarah Hopwood --- .../backends/cloud/openstack/openstack_container.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) -- 2.45.2