Skip to content

Commit

Permalink
HOT-FIX: Adiciona try/catch no Solr
Browse files Browse the repository at this point in the history
  • Loading branch information
cantuariavc authored and eribeiro committed Nov 23, 2020
1 parent 38e3146 commit 0355abd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docker/solr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ def __init__(self, url):
def get_num_docs(self, collection_name):
final_url = self.QUERY_DATA.format(self.url, collection_name)
res = requests.get(final_url)
dic = res.json()
num_docs = dic["response"]["numFound"]
return num_docs
if res.ok:
try:
dic = res.json()
return dic["response"]["numFound"]
except Exception as e:
print(F"Erro no get_num_docs: {e}")
print(res.content)

return 0

def list_collections(self):
req_url = self.LIST_COLLECTIONS.format(self.url)
Expand Down

0 comments on commit 0355abd

Please sign in to comment.