Compare commits

...

1 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
+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: