From 0355abde5563bc8f6ad98373592f75c738faa193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Mon, 23 Nov 2020 12:51:49 -0300 Subject: [PATCH] HOT-FIX: Adiciona try/catch no Solr --- docker/solr_api.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docker/solr_api.py b/docker/solr_api.py index 9bec45daa..7713619a2 100755 --- a/docker/solr_api.py +++ b/docker/solr_api.py @@ -27,9 +27,15 @@ class SolrClient: 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)