Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
|
|
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 |
|