File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import asyncio
22
33from fastapi import APIRouter
4+ from loguru import logger
45
56from lnbits .db import Database
67from lnbits .helpers import template_renderer
7- from lnbits .tasks import catch_everything_and_restart
8+ from lnbits .tasks import create_permanent_unique_task
89
910db = Database ("ext_example" )
1011
@@ -27,6 +28,15 @@ def example_renderer():
2728from .views_api import * # noqa: F401,F403
2829
2930
31+ scheduled_tasks : list [asyncio .Task ] = []
32+
33+ def example_stop ():
34+ for task in scheduled_tasks :
35+ try :
36+ task .cancel ()
37+ except Exception as ex :
38+ logger .warning (ex )
39+
3040def example_start ():
31- loop = asyncio . get_event_loop ( )
32- loop . create_task ( catch_everything_and_restart ( wait_for_paid_invoices ) )
41+ task = create_permanent_unique_task ( "ext_example" , wait_for_paid_invoices )
42+ scheduled_tasks . append ( task )
You can’t perform that action at this time.
0 commit comments