refactor: replace Trio with asyncio/uvloop

This commit is contained in:
Stefan Stammberger
2021-08-30 19:55:02 +02:00
parent fe79709698
commit d9849d43d2
21 changed files with 332 additions and 317 deletions
+5 -4
View File
@@ -1,5 +1,5 @@
import asyncio
from lnbits.helpers import url_for
import trio
import hmac
import httpx
from http import HTTPStatus
@@ -125,8 +125,9 @@ class OpenNodeWallet(Wallet):
return PaymentStatus(statuses[r.json()["data"]["status"]])
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
self.send, receive = trio.open_memory_channel(0)
async for value in receive:
self.queue = asyncio.Queue(0)
while True:
value = await self.queue.get()
yield value
async def webhook_listener(self):
@@ -141,5 +142,5 @@ class OpenNodeWallet(Wallet):
print("invalid webhook, not from opennode")
return "", HTTPStatus.NO_CONTENT
await self.send.send(charge_id)
await self.queue.put(charge_id)
return "", HTTPStatus.NO_CONTENT