File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
import asyncio
2
+ from loguru import logger
2
3
3
4
from fastapi import APIRouter
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_copilot" )
10
11
@@ -26,7 +27,17 @@ def copilot_renderer():
26
27
from .views import * # noqa
27
28
from .views_api import * # noqa
28
29
30
+ scheduled_tasks : list [asyncio .Task ] = []
31
+
32
+
33
+ def copilot_stop ():
34
+ for task in scheduled_tasks :
35
+ try :
36
+ task .cancel ()
37
+ except Exception as ex :
38
+ logger .warning (ex )
39
+
29
40
30
41
def copilot_start ():
31
- loop = asyncio . get_event_loop ( )
32
- loop . create_task ( catch_everything_and_restart ( wait_for_paid_invoices ) )
42
+ task = create_permanent_unique_task ( "ext_copilot" , wait_for_paid_invoices )
43
+ scheduled_tasks . append ( task )
You can’t perform that action at this time.
0 commit comments