buildman: address PR #11 comments

This commit is contained in:
Jimmy Zelinskie 2015-02-18 14:13:36 -05:00
parent 5790d7d8cc
commit f53dea46b7
5 changed files with 55 additions and 55 deletions

View file

@ -1,27 +1,26 @@
import logging
import boto
import thread
from Queue import Queue
from threading import Thread
logger = logging.getLogger(__name__)
queue = None
def get_queue(app):
"""
Returns a queue to the CloudWatchSender. If a queue/sender do not exist, creates them.
"""
global queue
if queue is None:
access_key = app.config.get('QUEUE_METRICS_AWS_ACCESS_KEY')
secret_key = app.config.get('QUEUE_METRICS_AWS_SECRET_KEY')
queue = Queue()
sender = CloudWatchSender(queue, access_key, secret_key)
sender.start()
else:
return queue
access_key = app.config.get('CLOUDWATCH_AWS_ACCESS_KEY')
secret_key = app.config.get('CLOUDWATCH_AWS_SECRET_KEY')
if None in (access_key, secret_key):
raise TypeError
queue = Queue()
sender = CloudWatchSender(queue, access_key, secret_key)
sender.start()
return queue
class CloudWatchSender(Thread):
"""