From d727655cdf810f88401f17755f21826146271251 Mon Sep 17 00:00:00 2001 From: Andy Sotheran Date: Tue, 6 Oct 2020 22:52:19 +0100 Subject: [PATCH] Revert "[06.10.20] Log timing and amq error handling" This reverts commit 2f94bac9 --- src/pricing/collector.py | 10 +++++----- src/utils/activemqConnect.py | 23 ++++++++--------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/pricing/collector.py b/src/pricing/collector.py index deabfb9..0985818 100644 --- a/src/pricing/collector.py +++ b/src/pricing/collector.py @@ -38,7 +38,7 @@ def averager(type): averagePrice = round(averagePrice, 2) log("Hourly Price for ({}) is {}".format(timestamp ,averagePrice), 'INFO') - sleep(0.5) + sleep(0.05) return averagePrice, timestamp @@ -124,9 +124,9 @@ def sentToArtemis(c_type, timestamp, av_price, high, low, vol, o_price, c_price) messageJson = json.dumps(message, indent = 4) log("Sending message to PricingSave queue", 'INFO') - sleep(0.5) + sleep(0.05) log("Message: {}".format(message), 'INFO') - sleep(0.5) + sleep(0.05) activeMQSender(messageJson) @@ -163,12 +163,12 @@ def collector(c_type): schedule.every().hour.at(time).do(collector, c_type).tag("collector") log("Collection will run again at {} every hour".format(time), 'INFO') - sleep(0.5) + sleep(0.05) # Dynamically Spin up Child process for each type wanting to track def collectorMain(c_type): log("== Historical Price Collector ==", 'INFO') - sleep(0.5) + sleep(0.05) collector(c_type) diff --git a/src/utils/activemqConnect.py b/src/utils/activemqConnect.py index 1e4fd5f..d62e240 100644 --- a/src/utils/activemqConnect.py +++ b/src/utils/activemqConnect.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import stomp -import os, sys +import os from src.utils.jsonLogger import log from time import sleep @@ -22,19 +22,12 @@ def activeMQSender(message): addr, port, mqUser, mqPass = keys().returnKeys() log("Attempting Connection to Artemis...", 'INFO') - sleep(1) - try: - con = stomp.Connection([(addr, port)], auto_content_length=False) - try: - con.connect( mqUser, mqPass, wait=True) + sleep(0.05) - con.send("PricingSave", message, content_type="application/json", headers={"Content-Type":"application/json"}) + con = stomp.Connection([(addr, port)], auto_content_length=False) + con.connect( mqUser, mqPass, wait=True) + + con.send("PricingSave", message, content_type="application/json", headers={"Content-Type":"application/json"}) + + con.disconnect() - except: - e = sys.exc_info()[0] - log("And Error occurred when sending to AMQ :: {}".format(e), 'ERR') - con.disconnect() - con.disconnect() - except: - e = sys.exc_info()[0] - log("And Error occurred when connecting to AMQ :: {}".format(e), 'ERR')