perf: the session's background watchers share two loops and one D-Bus service process (#575)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-14 01:02:24 -04:00
1 parent a0d3e03ca0
commit 7ea4efef98
4 files changed
+172 -137

No files matched your search

+20 -1
View File
@@ -22,6 +22,8 @@ IFACE = NAME + ".Manager"
@unittest.skipUnless(Gio and os.environ.get("DBUS_SESSION_BUS_ADDRESS"), "requires dbus-run-session and PyGObject")
class SleepHandshakeTest(unittest.TestCase):
ARGS = []
def setUp(self):
self.directory = tempfile.TemporaryDirectory()
self.dir = Path(self.directory.name)
@@ -35,7 +37,7 @@ class SleepHandshakeTest(unittest.TestCase):
lambda bus, sender, path, interface, name, body: self.signals.append(body.unpack()[0]))
env = dict(os.environ, BL_LAUNCH_DIR=str(self.dir),
DBUS_SYSTEM_BUS_ADDRESS=os.environ["DBUS_SESSION_BUS_ADDRESS"])
self.process = subprocess.Popen(["/usr/bin/python3", str(SCRIPT)], env=env,
self.process = subprocess.Popen(["/usr/bin/python3", str(SCRIPT), *self.ARGS], env=env,
stdout=subprocess.DEVNULL)
self.wait_for(lambda: (self.dir / "steam-sleep-ready").exists())
@@ -218,5 +220,22 @@ class SleepHandshakeTest(unittest.TestCase):
self.call(IFACE, "PowerOff", GLib.Variant("(b)", (True,)))
class WithNetworkManagerTest(SleepHandshakeTest):
ARGS = ["--with-netmanager"]
def owner(self, name):
return self.bus.call_sync("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
"GetConnectionUnixProcessID", GLib.Variant("(s)", (name,)), None,
Gio.DBusCallFlags.NONE, 2000, None).unpack()[0]
def test_one_process_owns_login1_and_networkmanager(self):
self.wait_for(lambda: self.bus.call_sync(
"org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameHasOwner",
GLib.Variant("(s)", ("org.freedesktop.NetworkManager",)), None,
Gio.DBusCallFlags.NONE, 2000, None).unpack()[0])
self.assertEqual(self.owner("org.freedesktop.NetworkManager"), self.process.pid)
self.assertEqual(self.owner(NAME), self.process.pid)
if __name__ == "__main__":
unittest.main()