[CHORE] cleanup cache and exception on make test (#1899)

* [CHORE] cleanup cache and exception on `make test`

moved the invalidate_forever task to proper location and use `create_permanent_task`.
and there was a Task never awaited Exception when running tests

* imrpove expiration test

* move cache into utils

* fix issue with pytest_asyncio

s

---------

Co-authored-by: jacksn <jkranawetter05@gmail.com>
This commit is contained in:
dni ⚡
2023-08-28 10:56:59 +01:00
committed by GitHub
co-authored by jacksn
parent 6077edad8f
commit 48f25488df
4 changed files with 24 additions and 18 deletions
+2 -3
View File
@@ -20,7 +20,6 @@ from slowapi import Limiter
from slowapi.util import get_remote_address
from starlette.responses import JSONResponse
from lnbits.cache import cache
from lnbits.core.crud import get_installed_extensions
from lnbits.core.helpers import migrate_extension_database
from lnbits.core.services import websocketUpdater
@@ -30,6 +29,7 @@ from lnbits.core.tasks import ( # register_watchdog,; unregister_watchdog,
)
from lnbits.settings import settings
from lnbits.tasks import cancel_all_tasks, create_permanent_task
from lnbits.utils.cache import cache
from lnbits.wallets import get_wallet_class, set_wallet_class
from .commands import db_versions, load_disabled_extension_list, migrate_databases
@@ -358,8 +358,6 @@ def register_startup(app: FastAPI):
if settings.lnbits_admin_ui:
initialize_server_logger()
asyncio.create_task(cache.invalidate_forever())
except Exception as e:
logger.error(str(e))
raise ImportError("Failed to run 'startup' event.")
@@ -431,6 +429,7 @@ def register_async_tasks(app):
create_permanent_task(check_pending_payments)
create_permanent_task(invoice_listener)
create_permanent_task(internal_invoice_listener)
create_permanent_task(cache.invalidate_forever)
register_task_listeners()
register_killswitch()
# await run_deferred_async() # calle: doesn't do anyting?