Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cria resiliência na chamada da API do DOU #5

Merged
merged 1 commit into from
Nov 18, 2021
Merged

Conversation

nitaibezerra
Copy link
Contributor

Adiciona um retry à chamada da API para o caso de qualquer eventual erro. Isso vai corrigir um erro de AttributeError na leitura do JSON.

@nitaibezerra nitaibezerra merged commit d66698f into main Nov 18, 2021
Copy link
Member

@augusto-herrmann augusto-herrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agora já foi. Fica como dívida técnica. 😄

field=field,
is_exact_search=is_exact_search,
)
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em geral devemos evitar usar a exceção genérica, e sim capturar a exceção específica que estava ocorrendo.

except:
logging.info('Sleeping for 30 seconds before retry dou_hook.search_text().')
time.sleep(30)
return self.dou_hook.search_text(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repetição de código aqui. Acho que o ideal seria colocar esse retry lá no requests mesmo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants