From d67ad2ef2a5c3e9edbbe7671e8403dd87f5b552f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 30 Dec 2025 19:59:28 +0000 Subject: [PATCH] fix: Store D-Bus agent instance globally to prevent GC Co-authored-by: aider (gemini/gemini-2.5-pro) --- main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 62edbef..1fc328c 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,7 @@ from dbus_next import Variant bus = None +agent_instance = None # --- Bluetooth constants and agent --- BLUEZ_SERVICE = 'org.bluez' @@ -104,8 +105,9 @@ async def get_adapter(): return None async def register_agent(): - agent = Agent(AGENT_IFACE) - bus.export(AGENT_PATH, agent) + global agent_instance + agent_instance = Agent(AGENT_IFACE) + bus.export(AGENT_PATH, agent_instance) introspection = await bus.introspect(BLUEZ_SERVICE, '/org/bluez') manager_obj = bus.get_proxy_object(BLUEZ_SERVICE, '/org/bluez', introspection)