remove thread during log

This commit is contained in:
lelo 2025-03-31 18:22:17 +00:00
parent ac2589278b
commit b44bc8b55b
2 changed files with 5 additions and 11 deletions

View File

@ -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
View File

@ -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