tAdd placeholder for signalling when server is stopped. - obelisk - Electrum server using libbitcoin as its backend
git clone https://git.parazyd.org/obelisk
Log
Files
Refs
README
LICENSE
---
commit e0fd14b6b5a9282c25a2c790793f9e70b2844a33
parent 614407fd1362c82a2af813a48ebbdecd4670838e
Author: parazyd 
Date:   Fri,  9 Apr 2021 00:10:14 +0200

Add placeholder for signalling when server is stopped.

Diffstat:
  M electrumobelisk/protocol.py         |       4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py
t@@ -54,6 +54,7 @@ class ElectrumProtocol(asyncio.Protocol):  # pylint: disable=R0904,R0902
     """Class implementing the Electrum protocol, with async support"""
     def __init__(self, log, chain, endpoints, server_cfg):
         self.log = log
+        self.stopped = False
         self.endpoints = endpoints
         self.server_cfg = server_cfg
         self.loop = asyncio.get_event_loop()
t@@ -115,11 +116,12 @@ class ElectrumProtocol(asyncio.Protocol):  # pylint: disable=R0904,R0902
         self.log.debug("ElectrumProtocol.stop()")
         if self.bx:
             await self.bx.stop()
+        self.stopped = True
 
     async def recv(self, reader, writer):
         """Loop ran upon a connection which acts as a JSON-RPC handler"""
         recv_buf = bytearray()
-        while True:
+        while not self.stopped:
             data = await reader.read(4096)
             if not data or len(data) == 0:
                 self.log.debug("Received EOF, disconnect")