diff --git a/src/wormhole/server/rendezvous.py b/src/wormhole/server/rendezvous.py index 5b15cf4..f047bbc 100644 --- a/src/wormhole/server/rendezvous.py +++ b/src/wormhole/server/rendezvous.py @@ -138,9 +138,6 @@ class Mailbox: stop_f() self._app.free_mailbox(self._mailbox_id) - def is_active(self): - return bool(self._listeners) - def _shutdown(self): # used at test shutdown to accelerate client disconnects for (send_f, stop_f) in self._listeners.values(): @@ -154,15 +151,6 @@ class AppNamespace: self._app_id = app_id self._mailboxes = {} - def is_active(self): - # An idle AppNamespace does not need to be kept in memory: it can be - # reconstructed from the DB if needed. And active one must be kept - # alive. - for mb in self._mailboxes.values(): - if mb.is_active(): - return True - return False - def get_nameplate_ids(self): db = self._db # TODO: filter this to numeric ids? @@ -558,10 +546,7 @@ class Rendezvous(service.MultiService): log.msg(" app prune checking %r" % (app_id,)) app = self.get_app(app_id) app.prune(now, old) - if not app.is_active(): # meaning no websockets - log.msg(" pruning idle app", app_id) - self._apps.pop(app_id) - log.msg("app prune ends, %d remaining apps" % len(self._apps)) + log.msg("app prune ends, %d apps" % len(self._apps)) def stopService(self): # This forcibly boots any clients that are still connected, which diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index f91adb9..96f49d6 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -324,23 +324,6 @@ class Prune(unittest.TestCase): rv.prune_all_apps(now=123, old=122) self.assertEqual(app.prune.mock_calls, [mock.call(123, 122)]) - def test_active(self): - rv = rendezvous.Rendezvous(get_db(":memory:"), None, None) - app = rv.get_app("appid1") - self.assertFalse(app.is_active()) - - mb = app.open_mailbox("mbid", "side1", 0) - self.assertFalse(mb.is_active()) - self.assertFalse(app.is_active()) - - mb.add_listener("handle", None, None) - self.assertTrue(mb.is_active()) - self.assertTrue(app.is_active()) - - mb.remove_listener("handle") - self.assertFalse(mb.is_active()) - self.assertFalse(app.is_active()) - def test_nameplates(self): db = get_db(":memory:") rv = rendezvous.Rendezvous(db, None, 3600)