Skip to content

Commit

Permalink
fix: poll for introspection data on startup
Browse files Browse the repository at this point in the history
Starting the DBus service via systemd and getting the introspection data
is a non atomic operation. The start call can return before the service
is fully running. As the introspection data is acquired from the DBus
service and not from the broker service, this call is not delayed until
the service is responding.

This exposes a more fundamental issue: Introspection and DBus activation
is simply incompatible.

To mitigate this, we retry the introspection for some time after
startup.

Signed-off-by: Felix Moessbauer <[email protected]>
  • Loading branch information
fmoessbauer committed Sep 19, 2024
1 parent bf2ee85 commit 23c4aef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion linux-entra-sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import struct
import uuid
import ctypes
import time
from signal import SIGINT
from threading import Thread, Lock
from gi.repository import GLib
Expand All @@ -27,6 +28,7 @@
# value can be used, if no real value is provided.
SSO_URL_DEFAULT = "https://login.microsoftonline.com/"
EDGE_BROWSER_CLIENT_ID = "d7b530a4-7680-4c23-a8bf-c52c121d2e87"
BROKER_START_TIMEOUT = 5
# dbus start service reply codes
START_REPLY_SUCCESS = 1
START_REPLY_ALREADY_RUNNING = 2
Expand Down Expand Up @@ -94,7 +96,13 @@ def _check_broker_online(self):
self.broker_online = False

def _instantiate_broker(self):
self.broker = self._bus.get(self.BROKER_NAME, self.BROKER_PATH)
timeout = time.time() + BROKER_START_TIMEOUT
while not self.broker and time.time() < timeout:
try:
self.broker = self._bus.get(self.BROKER_NAME, self.BROKER_PATH)
except GLib.Error:
time.sleep(0.1)
pass

def _monitor_bus(self):
self._bus.subscribe(
Expand Down

0 comments on commit 23c4aef

Please sign in to comment.