mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
lightning: use queueing lock
This commit is contained in:
parent
c3aa6e30cd
commit
8f681e13a2
1 changed files with 5 additions and 13 deletions
|
@ -1,4 +1,5 @@
|
|||
import functools
|
||||
import datetime
|
||||
import sys
|
||||
import struct
|
||||
import traceback
|
||||
|
@ -602,7 +603,7 @@ class LightningRPC:
|
|||
try:
|
||||
qitem = self.queue.get(block=False)
|
||||
except queue.Empty:
|
||||
await asyncio.sleep(1)
|
||||
await asyncio.sleep(5)
|
||||
pass
|
||||
else:
|
||||
def lightningRpcNetworkRequestThreadTarget(qitem):
|
||||
|
@ -686,31 +687,22 @@ class LightningWorker:
|
|||
NETWORK = self.network()
|
||||
CONFIG = self.config()
|
||||
|
||||
netAndWalLock.acquire()
|
||||
synced, local, server = isSynced()
|
||||
netAndWalLock.release()
|
||||
if not synced:
|
||||
await asyncio.sleep(5)
|
||||
continue
|
||||
else:
|
||||
if not wasAlreadyUpToDate:
|
||||
print("UP TO DATE FOR THE FIRST TIME")
|
||||
print(NETWORK.get_status_value("updated"))
|
||||
wasAlreadyUpToDate = True
|
||||
|
||||
writer = None
|
||||
print("OPENING CONNECTION")
|
||||
try:
|
||||
reader, writer = await asyncio.wait_for(asyncio.open_connection(machine, 1080), 5)
|
||||
writer.write(b"MAGIC")
|
||||
writer.write(privateKeyHash[:6])
|
||||
await asyncio.wait_for(writer.drain(), 5)
|
||||
while asyncio.get_event_loop().is_running():
|
||||
print(datetime.datetime.now(), "READING REQUEST")
|
||||
obj = await readJson(reader)
|
||||
if not obj: continue
|
||||
if "id" not in obj:
|
||||
print("Invoice update?", obj)
|
||||
for i in self.subscribers: i(obj)
|
||||
continue
|
||||
print(datetime.datetime.now(), "making reply")
|
||||
await asyncio.wait_for(readReqAndReply(obj, writer, netAndWalLock), 10)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
|
Loading…
Add table
Reference in a new issue