Commit 91c96078 authored by Alok Saldanha's avatar Alok Saldanha
Browse files

#9 fix race condition by grabbing lock before adding cache entry

parent 66f7a6b5
......@@ -11,7 +11,7 @@
import datetime
import os
import logging
from threading import Thread
from threading import Thread, Lock
import json
from flask import (
......@@ -168,15 +168,16 @@ def filecrawl():
rendered_html=rendered_html,
)
entry_lock = Lock()
@app.route("/view/<path:path>", methods=["GET", "PUT", "POST"])
def do_view(path):
dataset = get_dataset(path)
file_path = get_file_path(dataset)
match = cache.check_entry(dataset)
if match is None:
uascripts = get_extra_scripts()
match = cache.create_entry(dataset, file_path, uascripts)
with entry_lock:
match = cache.check_entry(dataset)
if match is None:
uascripts = get_extra_scripts()
match = cache.create_entry(dataset, file_path, uascripts)
match.timestamp = current_time_stamp()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment