kolibri-daemon hangs instead of exiting when it cannot claim its D-Bus name
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
When kolibri-daemon cannot claim its D-Bus name, it prints Failed to register: Unable to acquire bus name and then hangs instead of exiting.
Complexity: Low Target branch: develop
Context
Application.__init__callsself.hold()(application.py#L413-L415), which is released only when Kolibri attaches.- A failed registration never attaches Kolibri, so
g_application_run()keeps iterating on the held use count and never returns. main()blocks inawait_bus_name(), which returns only whenrun()does.- GApplication emits
startuponly on the primary instance, after registration succeeds (do_startup).
The Change
- Take the initial hold in
do_startupinstead of__init__, so a failed registration letsrun()return.
How to Get There
- Install the Devel flatpak.
- Start a private session bus:
dbus-run-session -- sh. - Hold the daemon's name:
flatpak run --command=python3 org.learningequality.Kolibri.Devel -c "from gi.repository import Gio, GLib; Gio.bus_own_name(Gio.BusType.SESSION, 'org.learningequality.Kolibri.Devel.Daemon', 0, None, None, None); GLib.MainLoop().run()" & - Run
flatpak run --command=/app/libexec/kolibri-app/kolibri-daemon org.learningequality.Kolibri.Devel --session: it printsFailed to registerand does not exit.
Acceptance Criteria
- [ ] When the daemon cannot claim its D-Bus name, it exits non-zero with no Kolibri process left running.
- [ ] First launch after an upgrade that runs migrations still shows the loading page, with no inactivity-timeout exit.
- [ ]
kolibri_daemon_testscoverrun()returning when the bus name is already owned.
AI usage
Claude Code reproduced the hang on a local build of #15349 and located it from a Python faulthandler stack dump.
There was an attempt to solve this in learningequality/kolibri-installer-gnome#77, but it broke some other things and needed to be reverted.
Fixed by #15349: the daemon now starts Kolibri only after it owns its bus name. kolibri-daemon --help on a build of that PR prints help, exits 0, and leaves no daemon process running.
Reopening: #15349 fixed --help, but a daemon that cannot claim its bus name still hangs after Failed to register. Issue rewritten to cover that.
Plan: A kolibri-daemon that cannot claim its D-Bus name returns from run() with a non-zero status instead of hanging.
- [ ] Take the startup hold in
do_startup - [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
--systemname loss already quits (exit 0, no hang) and stays unchanged, since only--sessionships; if AC1 covers--system,main()needs a non-zero status there.- AC2 is checked by a unit test plus CI's smoke test, not a manual upgrade run; if one is required, it needs a host where flatpak runs, which this sandbox refused while planning.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output