remove thread during log
This commit is contained in:
parent
ac2589278b
commit
b44bc8b55b
11
analytics.py
11
analytics.py
@ -9,16 +9,13 @@ import psycopg2
|
|||||||
|
|
||||||
file_access_temp = []
|
file_access_temp = []
|
||||||
|
|
||||||
# Thread-safe singleton metaclass.
|
# singleton metaclass.
|
||||||
class SingletonMeta(type):
|
class SingletonMeta(type):
|
||||||
_instances = {}
|
_instances = {}
|
||||||
_lock = threading.Lock() # Ensures thread safety.
|
|
||||||
|
|
||||||
def __call__(cls, *args, **kwargs):
|
def __call__(cls, *args, **kwargs):
|
||||||
with cls._lock:
|
if cls not in cls._instances:
|
||||||
if cls not in cls._instances:
|
instance = super().__call__(*args, **kwargs)
|
||||||
instance = super().__call__(*args, **kwargs)
|
cls._instances[cls] = instance
|
||||||
cls._instances[cls] = instance
|
|
||||||
return cls._instances[cls]
|
return cls._instances[cls]
|
||||||
|
|
||||||
# Database class that only handles the connection.
|
# Database class that only handles the connection.
|
||||||
|
|||||||
5
app.py
5
app.py
@ -269,10 +269,7 @@ def serve_file(subpath):
|
|||||||
logging = True
|
logging = True
|
||||||
|
|
||||||
if logging:
|
if logging:
|
||||||
threading.Thread(
|
a.log_file_access(subpath, filesize, mime, ip_address, user_agent, session['device_id'], bool(cached))
|
||||||
target=a.log_file_access,
|
|
||||||
args=(subpath, filesize, mime, ip_address, user_agent, session['device_id'], bool(cached), )
|
|
||||||
).start()
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user