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 json
import trio
import asyncio
import httpx
from os import getenv
from http import HTTPStatus
@@ -116,8 +116,9 @@ class LNPayWallet(Wallet):
return PaymentStatus(statuses[r.json()["settled"]])
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):
@@ -142,6 +143,6 @@ class LNPayWallet(Wallet):
)
data = r.json()
if data["settled"]:
await self.send.send(lntx_id)
await self.queue.put(lntx_id)
return "", HTTPStatus.NO_CONTENT