From 98c56798f5bba481956c943bc349de7c6ffc4fe4 Mon Sep 17 00:00:00 2001 From: Igor Tatarnikov Date: Wed, 23 Oct 2024 11:00:17 +0100 Subject: [PATCH] Added sleep call --- .../atlas_specific/allen_brain_atlas/gene_expression/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/brainrender/atlas_specific/allen_brain_atlas/gene_expression/api.py b/brainrender/atlas_specific/allen_brain_atlas/gene_expression/api.py index 85ed432..b044be0 100644 --- a/brainrender/atlas_specific/allen_brain_atlas/gene_expression/api.py +++ b/brainrender/atlas_specific/allen_brain_atlas/gene_expression/api.py @@ -1,5 +1,6 @@ import os import sys +from time import sleep import pandas as pd import requests @@ -89,6 +90,7 @@ def get_gene_experiments(self, gene): url = self.gene_experiments_url.replace("-GENE_SYMBOL-", gene) max_retries = 8 delay = 4 + data = None for i in range(max_retries): try: @@ -97,6 +99,7 @@ def get_gene_experiments(self, gene): except requests.exceptions.JSONDecodeError: print(f"Unable to connect to Allen API, retrying in {delay}") delay *= 2 + sleep(delay) if not len(data): print(f"No experiment found for gene {gene}")