JaishnaCodz commited on
Commit
e5db2cc
·
verified ·
1 Parent(s): 0fc20d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -99,7 +99,8 @@ async def review_blog(text_input, url_input):
99
  return "Review Blog", "Error: No input provided.", gr.update(visible=False)
100
 
101
  try:
102
- async with asyncio.timeout(30): # 30-second timeout for entire process
 
103
  # Handle URL input
104
  if input_type == "URL":
105
  button_text = "Fetching content..."
@@ -137,6 +138,9 @@ async def review_blog(text_input, url_input):
137
  except Exception as e:
138
  return "Review Blog", f"Error creating temporary file: {str(e)}", gr.update(visible=False)
139
 
 
 
 
140
  except asyncio.TimeoutError:
141
  return "Timeout", "Error: Process timed out after 30 seconds.", gr.update(visible=False)
142
 
 
99
  return "Review Blog", "Error: No input provided.", gr.update(visible=False)
100
 
101
  try:
102
+ # Use asyncio.wait_for for timeout in Python 3.10
103
+ async def process_with_timeout():
104
  # Handle URL input
105
  if input_type == "URL":
106
  button_text = "Fetching content..."
 
138
  except Exception as e:
139
  return "Review Blog", f"Error creating temporary file: {str(e)}", gr.update(visible=False)
140
 
141
+ # Run the process with a 30-second timeout
142
+ return await asyncio.wait_for(process_with_timeout(), timeout=30)
143
+
144
  except asyncio.TimeoutError:
145
  return "Timeout", "Error: Process timed out after 30 seconds.", gr.update(visible=False)
146