diff --git a/blueman/bluez/Base.py b/blueman/bluez/Base.py index af6458899..dde308734 100644 --- a/blueman/bluez/Base.py +++ b/blueman/bluez/Base.py @@ -7,6 +7,8 @@ from blueman.bluez.errors import parse_dbus_error, BluezDBusException import logging +DBUS_TIMEOUT = 10 * 1_000 + class BaseMeta(GObjectMeta): def __call__(cls, *args: object, **kwargs: str) -> "Base": @@ -92,7 +94,7 @@ def callback( else: logging.error(f"Unhandled error for {self.__proxy.get_interface_name()}.{method}", exc_info=True) - self.__proxy.call(method, param, Gio.DBusCallFlags.NONE, GLib.MAXINT, None, + self.__proxy.call(method, param, Gio.DBusCallFlags.NONE, DBUS_TIMEOUT, None, callback, reply_handler, error_handler) def get(self, name: str) -> Any: @@ -101,7 +103,7 @@ def get(self, name: str) -> Any: 'org.freedesktop.DBus.Properties.Get', GLib.Variant('(ss)', (self._interface_name, name)), Gio.DBusCallFlags.NONE, - GLib.MAXINT, + DBUS_TIMEOUT, None) return prop.unpack()[0] except GLib.Error as e: @@ -119,7 +121,7 @@ def set(self, name: str, value: str | int | bool) -> None: self.__proxy.call('org.freedesktop.DBus.Properties.Set', param, Gio.DBusCallFlags.NONE, - GLib.MAXINT, + DBUS_TIMEOUT, None) def get_object_path(self) -> ObjectPath: @@ -130,7 +132,7 @@ def get_properties(self) -> dict[str, Any]: res = self.__proxy.call_sync('org.freedesktop.DBus.Properties.GetAll', param, Gio.DBusCallFlags.NONE, - GLib.MAXINT, + DBUS_TIMEOUT, None) props: dict[str, Any] = res.unpack()[0] diff --git a/blueman/gui/manager/ManagerDeviceMenu.py b/blueman/gui/manager/ManagerDeviceMenu.py index 7e892e866..eb0645548 100644 --- a/blueman/gui/manager/ManagerDeviceMenu.py +++ b/blueman/gui/manager/ManagerDeviceMenu.py @@ -35,6 +35,8 @@ from blueman.gui.manager.ManagerDeviceList import ManagerDeviceList from blueman.main.Manager import Blueman +DBUS_TIMEOUT = 10 * 1_000 + class DeviceMenuItem: class Group(Enum): @@ -163,7 +165,7 @@ def fail(_obj: AppletService | None, result: GLib.Error, _user_data: None) -> No self._appl.ConnectService('(os)', device.get_object_path(), uuid, result_handler=success, error_handler=fail, - timeout=GLib.MAXINT) + timeout=DBUS_TIMEOUT) prog.start() @@ -183,7 +185,7 @@ def err(_obj: AppletService | None, result: GLib.Error, _user_date: None) -> Non return self._appl.DisconnectService('(osd)', device.get_object_path(), uuid, port, - result_handler=ok, error_handler=err, timeout=GLib.MAXINT) + result_handler=ok, error_handler=err, timeout=DBUS_TIMEOUT) def on_device_property_changed(self, lst: "ManagerDeviceList", _device: Device, tree_iter: Gtk.TreeIter, key_value: tuple[str, object]) -> None: