mirror of
https://github.com/zebrajr/ollama-webui.git
synced 2025-12-06 12:19:46 +01:00
refactor: format
Signed-off-by: Adam Tao <tcx4c70@gmail.com>
This commit is contained in:
parent
635cb8e3ff
commit
7bd7559bfe
|
|
@ -336,9 +336,7 @@ else:
|
||||||
except Exception:
|
except Exception:
|
||||||
DATABASE_POOL_RECYCLE = 3600
|
DATABASE_POOL_RECYCLE = 3600
|
||||||
|
|
||||||
DATABASE_ENABLE_SQLITE_WAL = (
|
DATABASE_ENABLE_SQLITE_WAL = (os.environ.get("DATABASE_ENABLE_SQLITE_WAL", "False").lower() == "true")
|
||||||
os.environ.get("DATABASE_ENABLE_SQLITE_WAL", "False").lower() == "true"
|
|
||||||
)
|
|
||||||
|
|
||||||
DATABASE_DEDUPLICATE_INTERVAL = (
|
DATABASE_DEDUPLICATE_INTERVAL = (
|
||||||
os.environ.get("DATABASE_DEDUPLICATE_INTERVAL", 0.)
|
os.environ.get("DATABASE_DEDUPLICATE_INTERVAL", 0.)
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ elif "sqlite" in SQLALCHEMY_DATABASE_URL:
|
||||||
engine = create_engine(
|
engine = create_engine(
|
||||||
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_connect(dbapi_connection, connection_record):
|
def on_connect(dbapi_connection, connection_record):
|
||||||
cursor = dbapi_connection.cursor()
|
cursor = dbapi_connection.cursor()
|
||||||
if DATABASE_ENABLE_SQLITE_WAL:
|
if DATABASE_ENABLE_SQLITE_WAL:
|
||||||
|
|
@ -122,6 +123,7 @@ elif "sqlite" in SQLALCHEMY_DATABASE_URL:
|
||||||
else:
|
else:
|
||||||
cursor.execute("PRAGMA journal_mode=DELETE")
|
cursor.execute("PRAGMA journal_mode=DELETE")
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
event.listen(engine, "connect", on_connect)
|
event.listen(engine, "connect", on_connect)
|
||||||
else:
|
else:
|
||||||
if isinstance(DATABASE_POOL_SIZE, int):
|
if isinstance(DATABASE_POOL_SIZE, int):
|
||||||
|
|
|
||||||
|
|
@ -500,6 +500,7 @@ def deduplicate(interval: float = 10.0):
|
||||||
|
|
||||||
:param interval: Duration in seconds to wait before allowing the function to be called again.
|
:param interval: Duration in seconds to wait before allowing the function to be called again.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
last_calls = {}
|
last_calls = {}
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
|
|
@ -514,6 +515,7 @@ def deduplicate(interval: float = 10.0):
|
||||||
return None
|
return None
|
||||||
last_calls[key] = now
|
last_calls[key] = now
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user