electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 277e5be229dd9baa7b055200c7f75dfd37197aaf
parent 0f6566d11e917f7a0da43d9f0cb9370f3c987c3f
Author: Janus <ysangkok@gmail.com>
Date:   Mon, 19 Mar 2018 12:14:39 +0100

lightning: use queueing lock

Diffstat:
Mlib/lightning.py | 18+++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/lib/lightning.py b/lib/lightning.py @@ -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()