7
7
from office365 .sharepoint .client_context import ClientContext
8
8
from office365 .sharepoint .files .file import File
9
9
from office365 .sharepoint .folders .folder import Folder
10
- from office365 .sharepoint .sharing .links .kind import SharingLinkKind
11
10
12
11
13
12
def handle_sharepoint_errors (max_retries = 5 , delay_seconds = 3 ):
@@ -26,7 +25,11 @@ def wrapper(self, *args, **kwargs):
26
25
return func (self , * args , ** kwargs )
27
26
except ClientRequestException as e :
28
27
last_exception = e
29
- if e .response .status_code == 403 :
28
+ if e .response .status_code == 429 :
29
+ print (f"Erro 429 (Muitas solicitações) detectado. Aguardando 60 segundos..." )
30
+ time .sleep (60 )
31
+ continue
32
+ elif e .response .status_code == 403 :
30
33
print ("Erro 403 (Proibido) detectado. Tentando relogar..." )
31
34
if not (self .username and self .password ):
32
35
print ("Credenciais não disponíveis para relogin. Abortando." )
@@ -35,7 +38,6 @@ def wrapper(self, *args, **kwargs):
35
38
if self .login (self .username , self .password ):
36
39
print ("Relogin bem-sucedido. Tentando a operação novamente." )
37
40
try :
38
- # Tenta a operação mais uma vez após o relogin
39
41
return func (self , * args , ** kwargs )
40
42
except ClientRequestException as e2 :
41
43
print (f"A operação falhou mesmo após o relogin: { e2 } " )
0 commit comments