Updated listener task to most recent
This commit is contained in:
parent
df48d2c638
commit
5fccd3c9c6
1 changed files with 11 additions and 3 deletions
14
__init__.py
14
__init__.py
|
|
@ -4,7 +4,7 @@ from fastapi import APIRouter
|
|||
|
||||
from lnbits.db import Database
|
||||
from lnbits.helpers import template_renderer
|
||||
from lnbits.tasks import catch_everything_and_restart
|
||||
from lnbits.tasks import create_permanent_unique_task
|
||||
|
||||
|
||||
db = Database("ext_myextension")
|
||||
|
|
@ -30,7 +30,15 @@ from .tasks import wait_for_paid_invoices
|
|||
from .views import *
|
||||
from .views_api import *
|
||||
|
||||
scheduled_tasks: list[asyncio.Task] = []
|
||||
|
||||
def myextension_stop():
|
||||
for task in scheduled_tasks:
|
||||
try:
|
||||
task.cancel()
|
||||
except Exception as ex:
|
||||
logger.warning(ex)
|
||||
|
||||
def myextension_start():
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
|
||||
task = create_permanent_unique_task("ext_myextension", wait_for_paid_invoices)
|
||||
scheduled_tasks.append(task)
|
||||
Loading…
Add table
Add a link
Reference in a new issue