enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 188 forks source link

RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached #375

Open teto opened 8 years ago

teto commented 8 years ago

Since my upgrade to ubuntu 16.04, I get this error on startup

Traceback (most recent call last):
  File "/home/teto/.i3/myStatus.py", line 129, in <module>
    on_rightclick=['urxvtc', '-e', 'ncmpcpp']
  File "/home/teto/i3pystatus/i3pystatus/core/__init__.py", line 109, in register
    return self.modules.append(module, *args, **kwargs)
  File "/home/teto/i3pystatus/i3pystatus/core/util.py", line 73, in append
    module, *args, **kwargs)
  File "/home/teto/i3pystatus/i3pystatus/core/imputil.py", line 47, in instanciate_class_from_module
    return self.instanciate_class_from_module(self.get_module(module), *args, **kwargs)
  File "/home/teto/i3pystatus/i3pystatus/core/imputil.py", line 45, in instanciate_class_from_module
    return self.get_class(module)(*args, **kwargs)
  File "/home/teto/i3pystatus/i3pystatus/core/modules.py", line 64, in __init__
    super(Module, self).__init__(*args, **kwargs)
  File "/home/teto/i3pystatus/i3pystatus/core/settings.py", line 88, in __init__
    protected = self.get_protected_settings(settings_source)
  File "/home/teto/i3pystatus/i3pystatus/core/settings.py", line 125, in get_protected_settings
    setting = self.get_setting_from_keyring(identifier, user_backend)
  File "/home/teto/i3pystatus/i3pystatus/core/settings.py", line 145, in get_setting_from_keyring
    return keyring.get_password(setting_identifier, getpass.getuser())
  File "/usr/lib/python3/dist-packages/keyring/core.py", line 42, in get_password
    return _keyring_backend.get_password(service_name, username)
  File "/usr/lib/python3/dist-packages/keyring/backends/SecretService.py", line 51, in get_password
    collection = self.get_default_collection()
  File "/usr/lib/python3/dist-packages/keyring/backends/SecretService.py", line 43, in get_default_collection
    collection.unlock()
  File "/usr/lib/python3/dist-packages/secretstorage/collection.py", line 63, in unlock
    return unlock_objects(self.bus, [self.collection_path], callback)
  File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 160, in unlock_objects
    return exec_prompt_glib(bus, prompt)[0]
  File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 128, in exec_prompt_glib
    exec_prompt(bus, prompt, callback)
  File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 116, in exec_prompt
    prompt_iface.connect_to_signal('Completed', new_callback)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 544, in connect_to_signal
    dbus_interface, **keywords)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 369, in connect_to_signal
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 148, in add_signal_receiver
    path, **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 400, in add_signal_receiver
    self._require_main_loop()
RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...)

If I restart i3bar, it's ok so I suspect a race condition since I boot in 4sec; i3pystatus might launch before dbus ?

enkore commented 8 years ago

Depends on who launches D-Bus in your session? I remember having similar issues years ago, moving some stuff from the WM start script into .xinitrc (which starts the WM as the last thing in my setup) solved them.

teto commented 8 years ago

I am on ubuntu 16.04, from pstree I see that systemd calls dbus-launch, is that correct ? From ps -ax, I seem to have a few processes running:

 3809 tty1     S      0:00 dbus-launch --autolaunch=ca5b9ee2d20a0f1641630a1d5528ef4e --binary-syntax --close-stderr
 3810 tty1     S      0:00 i3
 3814 ?        SNsl   0:00 /usr/lib/rtkit/rtkit-daemon
 3828 ?        Ss     0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
 3850 ?        Sl     0:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
 3855 ?        S      0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
 3857 ?        Sl     0:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session

when I restart i3, it always works. I don't know much about dbus

pkkm commented 7 years ago

Adding the following to core/__init__.py (at the top or in the constructor of Status) solved the problem for me:

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

I haven't submitted this as a pull request because I'm not sure if it's the right solution or just a hack that happens to work.

Minda1975 commented 6 years ago

Adding the following to core/__init__.py (at the top or in the constructor of Status) solved the problem for me

Hello. I encountered the same problem (i run Debian 9.5). Your tip solved my problem. It would be good if the developer of the program would pay attention to the solution to this problem and say what he thinks about it.

enkore commented 6 years ago

I have next to no idea about dbus. And even less idea about glib. The latter's mutual, though.

Minda1975 commented 6 years ago

I have next to no idea about dbus. And even less idea about glib. The latter's mutual, though.

Thank you for clarification on this. Pkkm solution works well. I will look at how it will continue.