From e5013d5bcabf3a7d997400d964efd3fc319aa724 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 21 Oct 2019 16:53:29 +0100 Subject: [PATCH 1/2] Dissables Flask logging --- pisa/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pisa/api.py b/pisa/api.py index 44fcb8c..af2e491 100644 --- a/pisa/api.py +++ b/pisa/api.py @@ -1,3 +1,4 @@ +import os import json from flask import Flask, request, Response, abort, jsonify @@ -11,6 +12,7 @@ from pisa.block_processor import BlockProcessor # ToDo: #5-add-async-to-api app = Flask(__name__) + HTTP_OK = 200 HTTP_BAD_REQUEST = 400 HTTP_SERVICE_UNAVAILABLE = 503 @@ -125,7 +127,8 @@ def start_api(): watcher = Watcher() inspector = Inspector() - # Setting Flask log t ERROR only so it does not mess with out logging + # Setting Flask log to ERROR only so it does not mess with out logging. Also disabling flask initial messages logging.getLogger('werkzeug').setLevel(logging.ERROR) + os.environ['WERKZEUG_RUN_MAIN'] = 'true' app.run(host=HOST, port=PORT) From 71ce7c46ec4c7720ceae2ca55fd7584a3fdd7a39 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 21 Oct 2019 16:54:48 +0100 Subject: [PATCH 2/2] Removes the parameters for do_subscribe + PEP8 --- pisa/responder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pisa/responder.py b/pisa/responder.py index dcce0a6..d5f0f63 100644 --- a/pisa/responder.py +++ b/pisa/responder.py @@ -88,20 +88,20 @@ class Responder: if confirmations == 0: self.unconfirmed_txs.append(justice_txid) - logger.info("New job added.", - dispute_txid=dispute_txid, justice_txid=justice_txid, appointment_end=appointment_end) + logger.info("New job added.", dispute_txid=dispute_txid, justice_txid=justice_txid, + appointment_end=appointment_end) if self.asleep: self.asleep = False self.block_queue = Queue() - zmq_thread = Thread(target=self.do_subscribe, args=[self.block_queue]) + zmq_thread = Thread(target=self.do_subscribe) responder = Thread(target=self.do_watch) zmq_thread.start() responder.start() - def do_subscribe(self, block_queue): + def do_subscribe(self): self.zmq_subscriber = ZMQHandler(parent='Responder') - self.zmq_subscriber.handle(block_queue) + self.zmq_subscriber.handle(self.block_queue) def do_watch(self): # ToDo: #9-add-data-persistence