5723e5d95d264e4a3eb6d2a36b519b177608f5fe jnavarr5 Tue Apr 15 09:16:34 2025 -0700 Fixing an infinte loop bug: Moving sleep and counter outside of the exception block so the count also increments during the else statement. Adding a message to the assert(False) line. No Remdmine. diff --git src/hg/utils/otto/panelApp/genes.py src/hg/utils/otto/panelApp/genes.py index b99245de927..af605280a3c 100755 --- src/hg/utils/otto/panelApp/genes.py +++ src/hg/utils/otto/panelApp/genes.py @@ -92,38 +92,37 @@ genes_no_location = list() syms = getGeneSymbols() for sym in syms: url = "https://panelapp.genomicsengland.co.uk/api/v1/genes/{}?format=json".format(sym) count = 0 while True: try: myResponse = requests.get(url) if myResponse.ok: break else: logging.error("Some error on %s, retrying after 1 minute (trial %d)" % (url, count)) - time.sleep(60) - - except: + except Exception: logging.error("HTTP error on %s, retrying after 1 minute (trial %d)" % (url, count)) - time.sleep(60) - count += 1 - if count > 10: - assert(False) # cannot get URL + + time.sleep(60) # Wait 1 minute before trying again + count += 1 # Count the number of tries before failing + if count > 10: # Quit afer 10 failed attempts + assert False, "Cannot get URL after 10 attempts" jsonData = myResponse.content #jData = myResponse.json() jData = json.loads(jsonData.decode()) jsonFh.write(jsonData) jsonFh.write("\n".encode()) res = jData['results'] num_gene_variant = len(res) count = 0 while count != num_gene_variant: temp_attribute_dictionary = dict() string_dict_key = 'gene_{}'.format(continuous_count)