From caa9966df61a9e4290d36af557adc3ede1a3674b Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 27 Apr 2020 14:08:30 -0500 Subject: Added timeout for when/if it does the REST API query, so it doesn't hang indefinitely --- wqflask/base/data_set.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index fd1dff5c..cab708ef 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -98,19 +98,22 @@ Publish or ProbeSet. E.g. if data: self.datasets = json.loads(data) else: #ZS: I don't think this should ever run unless Redis is emptied - data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content) - for species in data['datasets']: - for group in data['datasets'][species]: - for dataset_type in data['datasets'][species][group]: - for dataset in data['datasets'][species][group][dataset_type]: - short_dataset_name = dataset[1] - if dataset_type == "Phenotypes": - new_type = "Publish" - elif dataset_type == "Genotypes": - new_type = "Geno" - else: - new_type = "ProbeSet" - self.datasets[short_dataset_name] = new_type + try: + data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown", timeout = 5).content) + for species in data['datasets']: + for group in data['datasets'][species]: + for dataset_type in data['datasets'][species][group]: + for dataset in data['datasets'][species][group][dataset_type]: + short_dataset_name = dataset[1] + if dataset_type == "Phenotypes": + new_type = "Publish" + elif dataset_type == "Genotypes": + new_type = "Geno" + else: + new_type = "ProbeSet" + self.datasets[short_dataset_name] = new_type + except: + pass Redis.set("dataset_structure", json.dumps(self.datasets)) -- cgit v1.2.3