fix: raise Ollama timeout from 20s to 60s for all game generators
Lint / Shell (shellcheck) (push) Successful in 14s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 45s
Lint / Secret scan (gitleaks) (push) Successful in 5s

phi4-mini can queue behind other requests and take >20s under load,
causing TimeoutError and silent failures in wyr/riddle/hangman/scramble.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 00:57:54 -04:00
parent 82a3f24519
commit 6c00e8b4fd
+6 -6
View File
@@ -937,7 +937,7 @@ async def _generate_trivia_question(category: str) -> dict | None:
"The question should be clear, factual, and have exactly one correct answer." "The question should be clear, factual, and have exactly one correct answer."
) )
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/chat", f"{OLLAMA_URL}/api/chat",
@@ -1237,7 +1237,7 @@ async def _generate_hangman_word() -> dict | None:
) )
user_msg = "Pick a common English word between 5 and 8 letters (lowercase letters only, no hyphens or spaces) and give a short hint." user_msg = "Pick a common English word between 5 and 8 letters (lowercase letters only, no hyphens or spaces) and give a short hint."
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/chat", f"{OLLAMA_URL}/api/chat",
@@ -1444,7 +1444,7 @@ async def _generate_scramble_word() -> dict | None:
) )
user_msg = "Pick a common English word between 4 and 8 letters (lowercase letters only, no hyphens or spaces)." user_msg = "Pick a common English word between 4 and 8 letters (lowercase letters only, no hyphens or spaces)."
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/chat", f"{OLLAMA_URL}/api/chat",
@@ -1566,7 +1566,7 @@ async def _generate_wyr() -> dict | None:
) )
user_msg = "Generate a fun, creative Would You Rather question. Keep each option under 10 words." user_msg = "Generate a fun, creative Would You Rather question. Keep each option under 10 words."
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/chat", f"{OLLAMA_URL}/api/chat",
@@ -1664,7 +1664,7 @@ async def _generate_riddle() -> dict | None:
) )
user_msg = "Generate a clever riddle. The answer should be 1-4 words." user_msg = "Generate a clever riddle. The answer should be 1-4 words."
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/chat", f"{OLLAMA_URL}/api/chat",
@@ -1876,7 +1876,7 @@ async def _generate_story_opener() -> str | None:
"Just the opening sentence, no explanation or title." "Just the opening sentence, no explanation or title."
) )
try: try:
timeout = aiohttp.ClientTimeout(total=20) timeout = aiohttp.ClientTimeout(total=60)
async with aiohttp.ClientSession(timeout=timeout) as session: async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post( async with session.post(
f"{OLLAMA_URL}/api/generate", f"{OLLAMA_URL}/api/generate",