bug: telegram_lurker commit_loop asyncio task never executes #231

Open
opened 2026-03-08 16:25:54 +00:00 by Zeus · 0 comments
Collaborator

Problem

The _commit_loop background task in the telegram_lurker plugin never fires. Messages are written to JSONL files correctly, but the periodic git commit+push never happens.

Analysis

In start(), the plugin creates an asyncio task:

self._commit_task = asyncio.create_task(self._commit_loop())

However, start() is called during init_plugins() inside asyncio.run(plugin_system.init_plugins(...)) in cli.py:153. After init_plugins returns, that asyncio.run() completes and the event loop ends. The commit_task is created in that event loop but never gets a chance to execute because the loop finishes.

The main polling loop in the loop plugin likely creates its own event loop context, so the commit_task from start() is orphaned.

Evidence

  • Service running for 9+ hours, zero git commits produced
  • journalctl shows no commit-related output (neither success nor error)
  • Manual git status confirms untracked changes exist
  • _write_jsonl works correctly (synchronous, called from _on_message)
  • _git_commit works correctly when called manually

Expected Behavior

The commit_loop should fire every commit_interval seconds (default 60), staging all changes and committing.

Suggested Fix

Either:

  1. Register the commit_loop as a periodic task via the loop plugin's extension points (e.g. loop.on_tick)
  2. Use a threading.Timer instead of asyncio.create_task (since the actual git operations are subprocess-based anyway)
  3. Have the loop plugin provide a register_periodic_task() API for plugins that need background work

Workaround

External systemd timer (lurker-commit.timer) runs git add -A && git commit && git push hourly. Documented and deployed on olymp.

  • PR #208 (telegram-lurker plugin)
  • Issue #227 (headless mode)
## Problem The `_commit_loop` background task in the telegram_lurker plugin never fires. Messages are written to JSONL files correctly, but the periodic git commit+push never happens. ## Analysis In `start()`, the plugin creates an asyncio task: ```python self._commit_task = asyncio.create_task(self._commit_loop()) ``` However, `start()` is called during `init_plugins()` inside `asyncio.run(plugin_system.init_plugins(...))` in `cli.py:153`. After `init_plugins` returns, that `asyncio.run()` completes and the event loop ends. The commit_task is created in that event loop but never gets a chance to execute because the loop finishes. The main polling loop in the `loop` plugin likely creates its own event loop context, so the commit_task from `start()` is orphaned. ## Evidence - Service running for 9+ hours, zero git commits produced - `journalctl` shows no commit-related output (neither success nor error) - Manual `git status` confirms untracked changes exist - `_write_jsonl` works correctly (synchronous, called from `_on_message`) - `_git_commit` works correctly when called manually ## Expected Behavior The commit_loop should fire every `commit_interval` seconds (default 60), staging all changes and committing. ## Suggested Fix Either: 1. Register the commit_loop as a periodic task via the loop plugin's extension points (e.g. `loop.on_tick`) 2. Use a threading.Timer instead of asyncio.create_task (since the actual git operations are subprocess-based anyway) 3. Have the loop plugin provide a `register_periodic_task()` API for plugins that need background work ## Workaround External systemd timer (`lurker-commit.timer`) runs `git add -A && git commit && git push` hourly. Documented and deployed on olymp. ## Related - PR #208 (telegram-lurker plugin) - Issue #227 (headless mode)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ultanio/cobot#231
No description provided.