-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__init__.py
46 lines (34 loc) · 1.08 KB
/
__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
39
40
41
42
43
44
45
46
import asyncio
from fastapi import APIRouter
from loguru import logger
from lnbits.tasks import create_permanent_unique_task
from .crud import db
from .tasks import handle_execution_queue, handle_nwc
from .views import nwcprovider_router
from .views_api import nwcprovider_api_router
scheduled_tasks: list[asyncio.Task] = []
nwcprovider_ext: APIRouter = APIRouter(
prefix="/nwcprovider", tags=["NWC Service Provider"]
)
nwcprovider_ext.include_router(nwcprovider_router)
nwcprovider_ext.include_router(nwcprovider_api_router)
nwcprovider_static_files = [
{
"path": "/nwcprovider/static",
"name": "nwcprovider",
}
]
def nwcprovider_stop():
for task in scheduled_tasks:
try:
task.cancel()
except Exception as ex:
logger.warning(ex)
def nwcprovider_start():
task = create_permanent_unique_task("ext_nwcprovider", handle_nwc)
scheduled_tasks.append(task)
task = create_permanent_unique_task(
"ext_nwcprovider_execution_queue", handle_execution_queue
)
scheduled_tasks.append(task)
__all__ = ["db"]