diff --git a/linux-entra-sso.py b/linux-entra-sso.py index f34dbe8..f8a18bd 100755 --- a/linux-entra-sso.py +++ b/linux-entra-sso.py @@ -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 @@ -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 @@ -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(