buildreporter: does not execute in a coroutine!

This commit is contained in:
Jimmy Zelinskie 2015-02-18 17:11:45 -05:00
parent 0d38e0b00b
commit 9ab3554226
2 changed files with 6 additions and 7 deletions

View file

@ -11,7 +11,6 @@ class BuildReporter(object):
def report_completion_status(self, status): def report_completion_status(self, status):
""" """
Method to invoke the recording of build's completion status to a metric service. Method to invoke the recording of build's completion status to a metric service.
This must _not_ block because it is assumed to run in an event loop.
""" """
raise NotImplementedError raise NotImplementedError
@ -35,6 +34,9 @@ class CloudWatchBuildReporter(BuildReporter):
self._failed_name = failed_name self._failed_name = failed_name
self._incompleted_name = incompleted_name self._incompleted_name = incompleted_name
def _send_to_queue(self, *args, **kwargs):
self._queue.put((args, kwargs))
def report_completion_status(self, status): def report_completion_status(self, status):
if status == BuildJobResult.COMPLETE: if status == BuildJobResult.COMPLETE:
status_name = self._completed_name status_name = self._completed_name
@ -45,7 +47,7 @@ class CloudWatchBuildReporter(BuildReporter):
else: else:
return return
yield From(self._queue.put(self._namespace_name, status_name, 1, unit='Count')) self._send_to_queue(self._namespace_name, status_name, 1, unit='Count')
class BuildMetrics(object): class BuildMetrics(object):

View file

@ -1,6 +1,5 @@
import logging import logging
import boto import boto
import thread
from Queue import Queue from Queue import Queue
from threading import Thread from threading import Thread
@ -12,10 +11,8 @@ def get_queue(app):
""" """
Returns a queue to the CloudWatchSender. If a queue/sender do not exist, creates them. Returns a queue to the CloudWatchSender. If a queue/sender do not exist, creates them.
""" """
access_key = app.config.get('CLOUDWATCH_AWS_ACCESS_KEY') access_key = app.config['CLOUDWATCH_AWS_ACCESS_KEY']
secret_key = app.config.get('CLOUDWATCH_AWS_SECRET_KEY') secret_key = app.config['CLOUDWATCH_AWS_SECRET_KEY']
if None in (access_key, secret_key):
raise TypeError
queue = Queue() queue = Queue()
sender = CloudWatchSender(queue, access_key, secret_key) sender = CloudWatchSender(queue, access_key, secret_key)