Spaces:
Build error
Build error
Update main.py
Browse files127 unmodified lines128129130131131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161127 unmodified lines result_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data)) return {"response": result_data}
async def make_request(session, token, data, url):async def make_request(session, token, data, url, max_retries=3): headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token } for _ in range(max_retries): try: async with session.post(url, headers=headers, json=data) as response: response.raise_for_status() try: result_data = await response.json() except aiohttp.ContentTypeError: result_data = await response.text() print(result_data) return result_data except (asyncio.TimeoutError, aiohttp.ClientError, requests.exceptions.HTTPError) as e: print(f"Error: {e}.") if isinstance(e, (asyncio.TimeoutError, requests.exceptions.HTTPError)) and e.response.status in [502, 504]: print("Skipping retries for this error.") break
print("Retrying...") await asyncio.sleep(1) raise Exception("Max retries reached or skipping retries. Unable to make the request.")
async def make_request_old(session, token, data, url): headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + tokenmain.py+28-1