Skip to content

Commit

Permalink
fix: dev: Fixing some missing code and some prints @minor
Browse files Browse the repository at this point in the history
  • Loading branch information
geonexus committed Apr 13, 2015
1 parent bc44410 commit 7f5dddb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def process_request(request, tenantid, serverid):
if windowsize is []:
from facts import cloto_client
windowsize = cloto_client.get_window_size(tenantid)
mredis.insert_window_size(tenantid, windowsize)

# If the queue has the number of facts defined by the windows size, it returns the
# last window-size values (range) and calculates the media of them (in terms of memory and cpu)
Expand Down Expand Up @@ -249,18 +250,20 @@ def windowsize_updater():
queue=queue_name,
routing_key="windowsizes")

print('Waiting for windowizes')
logging.info('Waiting for windowsizes')

def callback(ch, method, properties, body):
try:

print("received fact: %s" % body)
logging.info("received fact: %s" % body)
tenantid = body.split(" ")[0]
windowsize = body.split(" ")[1]
mredis.insert_window_size(tenantid, windowsize)

except ValueError:
print("receiving an invalid body: " + body)
logging.info("receiving an invalid body: " + body)

except Exception as ex:
print("ERROR UPDATING WINDOWSIZE: " + ex.message)
logging.info("ERROR UPDATING WINDOWSIZE: " + ex.message)

channel.basic_consume(callback,
queue=queue_name,
Expand All @@ -269,7 +272,7 @@ def callback(ch, method, properties, body):
channel.start_consuming()
except Exception as ex:
if ex.message:
print("Error %s:" % ex.message)
logging.error("Error %s:" % ex.message)
finally:
connection.close()

Expand Down

0 comments on commit 7f5dddb

Please sign in to comment.