mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-29 00:11:36 +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 functools
|
||||||
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
import struct
|
import struct
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -602,7 +603,7 @@ class LightningRPC:
|
||||||
try:
|
try:
|
||||||
qitem = self.queue.get(block=False)
|
qitem = self.queue.get(block=False)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(5)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
def lightningRpcNetworkRequestThreadTarget(qitem):
|
def lightningRpcNetworkRequestThreadTarget(qitem):
|
||||||
|
@ -686,31 +687,22 @@ class LightningWorker:
|
||||||
NETWORK = self.network()
|
NETWORK = self.network()
|
||||||
CONFIG = self.config()
|
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
|
writer = None
|
||||||
|
print("OPENING CONNECTION")
|
||||||
try:
|
try:
|
||||||
reader, writer = await asyncio.wait_for(asyncio.open_connection(machine, 1080), 5)
|
reader, writer = await asyncio.wait_for(asyncio.open_connection(machine, 1080), 5)
|
||||||
writer.write(b"MAGIC")
|
writer.write(b"MAGIC")
|
||||||
writer.write(privateKeyHash[:6])
|
writer.write(privateKeyHash[:6])
|
||||||
await asyncio.wait_for(writer.drain(), 5)
|
await asyncio.wait_for(writer.drain(), 5)
|
||||||
while asyncio.get_event_loop().is_running():
|
while asyncio.get_event_loop().is_running():
|
||||||
|
print(datetime.datetime.now(), "READING REQUEST")
|
||||||
obj = await readJson(reader)
|
obj = await readJson(reader)
|
||||||
if not obj: continue
|
if not obj: continue
|
||||||
if "id" not in obj:
|
if "id" not in obj:
|
||||||
print("Invoice update?", obj)
|
print("Invoice update?", obj)
|
||||||
for i in self.subscribers: i(obj)
|
for i in self.subscribers: i(obj)
|
||||||
continue
|
continue
|
||||||
|
print(datetime.datetime.now(), "making reply")
|
||||||
await asyncio.wait_for(readReqAndReply(obj, writer, netAndWalLock), 10)
|
await asyncio.wait_for(readReqAndReply(obj, writer, netAndWalLock), 10)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
Loading…
Add table
Reference in a new issue