From 9ab3554226186d35f71e79b1d0b1f88487e62417 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 18 Feb 2015 17:11:45 -0500 Subject: [PATCH] buildreporter: does not execute in a coroutine! --- buildman/jobutil/buildreporter.py | 6 ++++-- util/cloudwatch.py | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/buildman/jobutil/buildreporter.py b/buildman/jobutil/buildreporter.py index 992b7a06e..16dd0ca5b 100644 --- a/buildman/jobutil/buildreporter.py +++ b/buildman/jobutil/buildreporter.py @@ -11,7 +11,6 @@ class BuildReporter(object): def report_completion_status(self, status): """ 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 @@ -35,6 +34,9 @@ class CloudWatchBuildReporter(BuildReporter): self._failed_name = failed_name self._incompleted_name = incompleted_name + def _send_to_queue(self, *args, **kwargs): + self._queue.put((args, kwargs)) + def report_completion_status(self, status): if status == BuildJobResult.COMPLETE: status_name = self._completed_name @@ -45,7 +47,7 @@ class CloudWatchBuildReporter(BuildReporter): else: 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): diff --git a/util/cloudwatch.py b/util/cloudwatch.py index eca563164..b75dadf31 100644 --- a/util/cloudwatch.py +++ b/util/cloudwatch.py @@ -1,6 +1,5 @@ import logging import boto -import thread from Queue import Queue 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. """ - 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 + access_key = app.config['CLOUDWATCH_AWS_ACCESS_KEY'] + secret_key = app.config['CLOUDWATCH_AWS_SECRET_KEY'] queue = Queue() sender = CloudWatchSender(queue, access_key, secret_key)