Skip to content

CLI tool commands hang after displaying output #461

Closed

Description

@divideby0

Bug Description

CLI commands like basic-memory tool --help and basic-memory status hang indefinitely after displaying output, requiring Ctrl+C to exit.

Reproduction Steps

  1. Run uvx basic-memory tool --help
  2. Observe: help text displays but process never exits
  3. Must Ctrl+C to terminate

Also affects:

  • basic-memory tool write-note --help
  • basic-memory tool read-note --help
  • basic-memory tool search-notes --help
  • basic-memory status

Expected Behavior

Command should exit with code 0 after displaying output.

Root Cause

ensure_initialization() and CLI commands create database connections via asyncio.run() that are never cleaned up. The global database engine holds async connections that prevent the process from exiting.

Environment

  • basic-memory version: 0.16.x
  • Python: 3.12+
  • Platform: macOS/Linux

Activity

  1. divideby0 commented on Dec 20, 2025

    @divideby0
    ContributorAuthor

    this one might be a bit of a blocker for some as even basic-memory project add... hangs. i noticed there were some ci failures on my pull request but they seem to be unrelated to the changes:

    $ uvx basic-memory@latest project add taskmaster-merge ./context/memory
    Installed 105 packages in 407ms
    
    2025-12-20 15:18:39.836 | DEBUG    | basic_memory.api.template_loader:__init__:235 - Initialized template loader with directory: /Users/myuser/.cache/uv/archive-v0/q0WNp3Nb94j1OvizJA01-/lib/python3.12/site-packages/basic_memory/templates
    Project 'taskmaster-merge' added successfully
    
    # After manually hitting Ctrl+C
    
    ^CException ignored in: <module 'threading' from '/Users/myuser/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/threading.py'>
    Traceback (most recent call last):
      File "/Users/myuser/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/lib/python3.12/threading.py", line 1624, in _shutdown
        lock.acquire()
    KeyboardInterrupt: 
  2. phernandez commented on Dec 24, 2025

    @phernandez
    Member

    fixed with #471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions