ultrabug / py3status

py3status is an extensible i3status wrapper written in python
https://ultrabug.github.io/py3status/
BSD 3-Clause "New" or "Revised" License
893 stars 261 forks source link

bluetooth: reinitialize dbus #2221

Closed lasers closed 9 months ago

lasers commented 10 months ago

I wonder if it is a race condition. Untested. Trying to catch this exception.

Closes https://github.com/ultrabug/py3status/issues/2218.

lasers commented 10 months ago

SERVICE_UNKNOWN

FOUND IT -- Something like this.

syyyr commented 10 months ago

Okay, your patch almost works, but it needed this patch:

diff --git a/py3status/modules/bluetooth.py b/py3status/modules/bluetooth.py
index cb9a8638..a7b36371 100644
--- a/py3status/modules/bluetooth.py
+++ b/py3status/modules/bluetooth.py
@@ -130,7 +130,7 @@ class Py3status:
                 self.py3.log(" --- SUCCESS ---")
             except GLib.Error as err:
                 self.py3.log(" --- FAILED ---")
-                if err.matches(Gio.io_error_quark(), Gio.DBusError.SERVICE_UNKNOWN):
+                if err.matches(Gio.dbus_error_quark(), Gio.DBusError.SERVICE_UNKNOWN):
                     self._dbus_init()
                     self.py3.log(" --- MATCHED ---")
                 else:

If we want to match the dbus error, we must get the dbus error quark instead of io error quark

syyyr commented 10 months ago

Just FYI, as of now (92b76c66a78d601161eeacd4bd1b414363693c9d), the PR works for me.

lasers commented 10 months ago

OK. The next one should be same. I think retrying loop might be unnecessary since trying it once should be enough... and if it failed for some reason, giving it some time for the next one (10s) should be more than enough. I'm guessing the post_config_hook method isn't covered in py3status module error retries.

EDIT: You can use this for a while... Once you confirm it's working fine, I'll squash the commit and we call it a day.

syyyr commented 10 months ago

I have tested again, and it works. I'll use this for a bit and then get back to you after a week or so to confirm that the issue didn't reappear.

Thank you!

syyyr commented 9 months ago

Hi, I haven't had any problems for the past week, so I think the patch is correct.

ultrabug commented 9 months ago

Thanks!