Compare commits

...

2 Commits

Author SHA1 Message Date
claude[bot] 71cdf742e4 fix: remove loop.close() to prevent executor shutdown in MCP daemon thread
The MCP server runs file synchronization in a daemon thread with its own
event loop. Previously, the finally block called loop.close() which shut
down the ThreadPoolExecutor before background sync tasks completed.

This caused background tasks using aiofiles.os.scandir() to fail with
'cannot schedule new futures after shutdown' errors, preventing files
from being indexed in the database.

Since this is a daemon thread meant to run for the lifetime of the MCP
server process, the event loop should never be closed. The OS will clean
up resources when the process exits.

Fixes #443

Co-authored-by: jope-bm <jope-bm@users.noreply.github.com>
2025-11-25 03:10:12 +00:00
phernandez 10c7c19c03 fix db url for sqlite migrations
Signed-off-by: phernandez <paul@basicmachines.co>
2025-11-21 13:21:20 -06:00
2 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -67,8 +67,9 @@ if not config.cloud_mode_enabled:
loop.run_until_complete(initialize_file_sync(app_config))
except Exception as e:
logger.error(f"File sync error: {e}", err=True)
finally:
loop.close()
# Note: Do NOT close the loop here! This is a daemon thread that should
# run until process exit. Closing the loop shuts down the ThreadPoolExecutor
# which breaks aiofiles operations in background sync tasks.
logger.info(f"Sync changes enabled: {app_config.sync_changes}")
if app_config.sync_changes:
+4 -3
View File
@@ -56,9 +56,7 @@ class DatabaseType(Enum):
if config.database_backend == DatabaseBackend.POSTGRES:
if not config.database_url:
raise ValueError("DATABASE_URL must be set when using Postgres backend")
logger.info(
f"Using Postgres database: {config.database_url.split('@')[1] if '@' in config.database_url else config.database_url}"
)
logger.info(f"Using Postgres database: {config.database_url}")
return config.database_url
# Default to SQLite
@@ -332,6 +330,9 @@ async def run_migrations(
if app_config.database_backend == DatabaseBackend.POSTGRES:
# Convert asyncpg URL to psycopg2 URL for Alembic
db_url = db_url.replace("postgresql+asyncpg://", "postgresql://")
elif app_config.database_backend == DatabaseBackend.SQLITE:
# Convert aiosqlite URL to pysqlite URL for Alembic
db_url = db_url.replace("sqlite+aiosqlite://", "sqlite:///")
config.set_main_option("sqlalchemy.url", db_url)