mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Clear in memory cache every after api calls in unit tests
This commit is contained in:
@@ -7,11 +7,21 @@ from typing import Union
|
||||
|
||||
from bottle import Bottle
|
||||
|
||||
from optuna_dashboard._storage import trials_cache
|
||||
from optuna_dashboard._storage import trials_cache_lock
|
||||
from optuna_dashboard._storage import trials_last_fetched_at
|
||||
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from _typeshed.wsgi import WSGIEnvironment
|
||||
|
||||
|
||||
def clear_inmemory_cache() -> None:
|
||||
with trials_cache_lock:
|
||||
trials_cache.clear()
|
||||
trials_last_fetched_at.clear()
|
||||
|
||||
|
||||
def create_wsgi_env(
|
||||
path: str,
|
||||
method: str,
|
||||
@@ -66,6 +76,8 @@ def send_request(
|
||||
headers = headers or {}
|
||||
queries = queries or {}
|
||||
env = create_wsgi_env(path, method, content_type, bytes_body, queries, headers)
|
||||
|
||||
clear_inmemory_cache()
|
||||
response_body = b""
|
||||
iterable_body = app(env, start_response)
|
||||
for b in iterable_body:
|
||||
|
||||
Reference in New Issue
Block a user