-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
38 lines (28 loc) · 944 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import asyncio
from fastapi import APIRouter
from loguru import logger
from .crud import db
from .tasks import wait_for_paid_invoices
from .views import scrub_generic_router
from .views_api import scrub_api_router
scheduled_tasks: list[asyncio.Task] = []
scrub_static_files = [
{
"path": "/scrub/static",
"name": "scrub_static",
}
]
scrub_ext: APIRouter = APIRouter(prefix="/scrub", tags=["scrub"])
scrub_ext.include_router(scrub_generic_router)
scrub_ext.include_router(scrub_api_router)
def scrub_stop():
for task in scheduled_tasks:
try:
task.cancel()
except Exception as ex:
logger.warning(ex)
def scrub_start():
from lnbits.tasks import create_permanent_unique_task
task = create_permanent_unique_task("ext_scrub", wait_for_paid_invoices)
scheduled_tasks.append(task)
__all__ = ["db", "scrub_ext", "scrub_start", "scrub_stop", "scrub_static_files"]