Claude Code Claude Opus 4.6 commited on
Commit
b83c083
·
1 Parent(s): 0c309de

fix: Don't log asyncio.CancelledError as error - it's normal behavior

Browse files

CancelledError is raised when async tasks are cancelled during shutdown
or connection close. This is normal asyncio behavior and should not be
logged as an error or counted in error metrics.

Fixes RUNTIME_ERROR caused by httpcore connection close triggering
async task cancellation in Gradio's internal queue operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -183,7 +183,7 @@ async def safe_async_wrapper(coro, operation_name: str = "async_operation"):
183
  return result
184
  except asyncio.CancelledError:
185
  logger.info(f"[ASYNC_CANCEL] {operation_name} was cancelled at {datetime.utcnow().isoformat()}Z")
186
- write_error_log("async_cancelled", operation_name, "Operation was cancelled by asyncio")
187
  raise # Re-raise to allow proper cleanup
188
  except Exception as e:
189
  logger.error(f"[ASYNC_ERROR] {operation_name} failed: {e}")
 
183
  return result
184
  except asyncio.CancelledError:
185
  logger.info(f"[ASYNC_CANCEL] {operation_name} was cancelled at {datetime.utcnow().isoformat()}Z")
186
+ # CancelledError is normal asyncio behavior - do NOT log as error
187
  raise # Re-raise to allow proper cleanup
188
  except Exception as e:
189
  logger.error(f"[ASYNC_ERROR] {operation_name} failed: {e}")