File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
import asyncio
2
2
3
3
from fastapi import APIRouter
4
+ from loguru import logger
4
5
5
6
from lnbits .db import Database
6
7
from lnbits .helpers import template_renderer
7
- from lnbits .tasks import catch_everything_and_restart
8
+ from lnbits .tasks import create_permanent_unique_task
8
9
9
10
db = Database ("ext_example" )
10
11
@@ -27,6 +28,15 @@ def example_renderer():
27
28
from .views_api import * # noqa: F401,F403
28
29
29
30
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
+
30
40
def 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