fix: create coroutine inside worker thread for asyncio.run

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 <noreply@anthropic.com>
This commit is contained in:
AndyMik90
2025-12-20 14:31:18 +01:00
parent b9797cbe21
commit f89e4e6c56
+5 -2
View File
@@ -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))