From f89e4e6c562a68c3ddcf4f2501b724883b56edc6 Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Sat, 20 Dec 2025 14:31:18 +0100 Subject: [PATCH] fix: create coroutine inside worker thread for asyncio.run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The coroutine was being created on the main thread before being passed to ThreadPoolExecutor. This is incorrect as coroutines should be created and run in the same thread. Use a lambda to defer coroutine creation until execution inside the worker thread. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- auto-claude/commit_message.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auto-claude/commit_message.py b/auto-claude/commit_message.py index 1fe771ac..fd3476e1 100644 --- a/auto-claude/commit_message.py +++ b/auto-claude/commit_message.py @@ -282,11 +282,14 @@ def generate_commit_message_sync( loop = None if loop and loop.is_running(): - # Already in an async context - create a new thread to run + # Already in an async context - run in a new thread + # Use lambda to ensure coroutine is created inside the worker thread import concurrent.futures with concurrent.futures.ThreadPoolExecutor() as pool: - result = pool.submit(asyncio.run, _call_claude_haiku(prompt)).result() + result = pool.submit( + lambda: asyncio.run(_call_claude_haiku(prompt)) + ).result() else: result = asyncio.run(_call_claude_haiku(prompt))