mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-02 15:38:12 +08:00
#9 fix race condition by grabbing lock before adding cache entry
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from threading import Thread
|
from threading import Thread, Lock
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
@@ -168,15 +168,16 @@ def filecrawl():
|
|||||||
rendered_html=rendered_html,
|
rendered_html=rendered_html,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entry_lock = Lock()
|
||||||
@app.route("/view/<path:path>", methods=["GET", "PUT", "POST"])
|
@app.route("/view/<path:path>", methods=["GET", "PUT", "POST"])
|
||||||
def do_view(path):
|
def do_view(path):
|
||||||
dataset = get_dataset(path)
|
dataset = get_dataset(path)
|
||||||
file_path = get_file_path(dataset)
|
file_path = get_file_path(dataset)
|
||||||
match = cache.check_entry(dataset)
|
with entry_lock:
|
||||||
if match is None:
|
match = cache.check_entry(dataset)
|
||||||
uascripts = get_extra_scripts()
|
if match is None:
|
||||||
match = cache.create_entry(dataset, file_path, uascripts)
|
uascripts = get_extra_scripts()
|
||||||
|
match = cache.create_entry(dataset, file_path, uascripts)
|
||||||
|
|
||||||
match.timestamp = current_time_stamp()
|
match.timestamp = current_time_stamp()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user