aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/data_set.py
diff options
context:
space:
mode:
authorzsloan2020-04-27 14:08:30 -0500
committerzsloan2020-04-27 14:08:30 -0500
commitcaa9966df61a9e4290d36af557adc3ede1a3674b (patch)
tree35549625bd7c9198a7a59b8cf39ca30d5ac16973 /wqflask/base/data_set.py
parent75ecdb25c7a598f0f254f4f53529b657736aaa49 (diff)
downloadgenenetwork2-caa9966df61a9e4290d36af557adc3ede1a3674b.tar.gz
Added timeout for when/if it does the REST API query, so it doesn't hang indefinitely
Diffstat (limited to 'wqflask/base/data_set.py')
-rw-r--r--wqflask/base/data_set.py29
1 files 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))