Skip to content

Commit 554c3d7

Browse files
phernandezclaude
andcommitted
fix: set Windows event loop policy at CLI entry point
Move the WindowsSelectorEventLoopPolicy setting to the very top of main.py, before any imports. This ensures the policy is set before any asyncio code is triggered during module imports. The previous fix in initialization.py was too late - by the time ensure_initialization() runs, imports have already triggered asyncio code with the default ProactorEventLoop. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent db50447 commit 554c3d7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/basic_memory/cli/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
"""Main CLI entry point for basic-memory.""" # pragma: no cover
22

3+
# Set Windows event loop policy BEFORE any imports that might use asyncio.
4+
# The ProactorEventLoop (Windows default) can crash with "IndexError: pop from
5+
# an empty deque" during cleanup. SelectorEventLoop is more stable for CLI use.
6+
import sys # pragma: no cover
7+
8+
if sys.platform == "win32": # pragma: no cover
9+
import asyncio
10+
11+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
12+
313
from basic_memory.cli.app import app # pragma: no cover
414

515
# Register commands

0 commit comments

Comments
 (0)