Performance improvements (#19)

* fix: increase the wait time for re-connecting to a relay

* fix: blocking sleep

* fix: remove blocking sleep

* fix: allow multiple filters per request
This commit is contained in:
Vlad Stan 2023-09-12 15:06:28 +03:00 committed by GitHub
parent 9d9fbc0189
commit e6624f76bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 18 deletions

View file

@ -1,3 +1,4 @@
import asyncio
import json
import time
from queue import Queue
@ -95,7 +96,7 @@ class Relay:
json_str = json.dumps(["REQ", s["id"], s["filters"][0]])
self.publish(json_str)
def queue_worker(self):
async def queue_worker(self):
while True:
if self.connected:
try:
@ -105,7 +106,7 @@ class Relay:
except:
pass
else:
time.sleep(0.1)
await asyncio.sleep(1)
if self.shutdown:
logger.warning(f"Closing queue worker for '{self.url}'.")