Tu Nombre commited on
Commit
f0924f1
·
1 Parent(s): b0159c2

retry uploads con delay

Browse files
Files changed (1) hide show
  1. main.py +10 -5
main.py CHANGED
@@ -196,11 +196,16 @@ CMD [\"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"]""
196
  {"path": f"media_{nombre}", "content": contenido_b64, "encoding": "base64"}
197
  ]
198
  }
199
- r_up = await client.post(
200
- f"https://huggingface.co/api/spaces/{repo_name}/commit/main",
201
- headers={"Authorization": f"Bearer {token_actual}", "Content-Type": "application/json"},
202
- content=_json.dumps(commit_arc).encode()
203
- )
 
 
 
 
 
204
  print(f"Upload {nombre}: {r_up.status_code}", flush=True)
205
  except Exception as e:
206
  print(f"Error upload {arc.get('nombre','?')}: {e}", flush=True)
 
196
  {"path": f"media_{nombre}", "content": contenido_b64, "encoding": "base64"}
197
  ]
198
  }
199
+ # 3 intentos con espera
200
+ for intento in range(3):
201
+ r_up = await client.post(
202
+ f"https://huggingface.co/api/spaces/{repo_name}/commit/main",
203
+ headers={"Authorization": f"Bearer {token_actual}", "Content-Type": "application/json"},
204
+ content=_json.dumps(commit_arc).encode()
205
+ )
206
+ if r_up.status_code in [200, 201]:
207
+ break
208
+ await asyncio.sleep(2)
209
  print(f"Upload {nombre}: {r_up.status_code}", flush=True)
210
  except Exception as e:
211
  print(f"Error upload {arc.get('nombre','?')}: {e}", flush=True)