diff --git a/pisa/api.py b/pisa/api.py index 6d553c1..1b05ae1 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 from binascii import hexlify @@ -12,6 +13,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 @@ -135,7 +137,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) 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