From 9050fdcea68bbeb5034ae78a463409db338e420c Mon Sep 17 00:00:00 2001 From: meejah Date: Sat, 24 Aug 2019 12:31:08 -0600 Subject: [PATCH] explicitly save refs to webish and operations (instead of using Service methods) --- src/allmydata/client.py | 6 ++++++ src/allmydata/web/directory.py | 2 +- src/allmydata/webish.py | 12 +++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 360aa568f..a57954145 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -496,6 +496,12 @@ class _Client(node.Node, pollmixin.PollMixin): def get_long_tubid(self): return idlib.nodeid_b2a(self.nodeid) + def get_web_service(self): + """ + :return: a reference to our web server + """ + return self.getServiceNamed("webish") + def _init_permutation_seed(self, ss): seed = self.config.get_config_from_file("permutation-seed") if not seed: diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index b429b06ec..c7405f848 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -62,7 +62,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin): self.node = node self.parentnode = parentnode self.name = name - self._operations = client.getServiceNamed("webish").getServiceNamed("operations") + self._operations = client.get_web_service().get_operations() def childFactory(self, ctx, name): name = name.decode("utf-8") diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 2a5ec2d94..d9f4bd740 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -168,9 +168,9 @@ class WebishServer(service.MultiService): # If set, clock is a twisted.internet.task.Clock that the tests # use to test ophandle expiration. - operations = OphandleTable(clock) - operations.setServiceParent(self) - self.root.putChild("operations", operations) + self._operations = OphandleTable(clock) + self._operations.setServiceParent(self) + self.root.putChild("operations", self._operations) def buildServer(self, webport, nodeurl_path, staticdir): self.webport = webport @@ -241,6 +241,12 @@ class WebishServer(service.MultiService): # who knows, probably some weirdo future version of Twisted self._started.errback(AssertionError("couldn't find out the scheme or port for the web-API server")) + def get_operations(self): + """ + :return: a reference to our "active operations" tracker + """ + return self._operations + class IntroducerWebishServer(WebishServer): def __init__(self, introducer, webport, nodeurl_path=None, staticdir=None):