From 87cc3289a02d92ccba11f6981b30462fe0c2bb59 Mon Sep 17 00:00:00 2001 From: Matt Jibson Date: Tue, 6 Oct 2015 01:28:43 -0400 Subject: [PATCH] Remove transaction from metric reporting --- buildman/server.py | 2 +- data/queue.py | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/buildman/server.py b/buildman/server.py index f2a4feb92..80776f6e2 100644 --- a/buildman/server.py +++ b/buildman/server.py @@ -65,7 +65,7 @@ class BuilderServer(object): @controller_app.route('/status') def status(): - metrics = server._queue.get_metrics(require_transaction=False) + metrics = server._queue.get_metrics() (running_count, available_not_running_count, available_count) = metrics workers = [component for component in server._current_components diff --git a/data/queue.py b/data/queue.py index c5e5dad72..3ce6c7a6f 100644 --- a/data/queue.py +++ b/data/queue.py @@ -67,22 +67,20 @@ class WorkQueue(object): def _item_by_id_for_update(self, queue_id): return db_for_update(QueueItem.select().where(QueueItem.id == queue_id)).get() - def get_metrics(self, require_transaction=True): - guard = self._transaction_factory(db) if require_transaction else NoopWith() - with guard: - now = datetime.utcnow() - name_match_query = self._name_match_query() + def get_metrics(self): + now = datetime.utcnow() + name_match_query = self._name_match_query() - running_query = self._running_jobs(now, name_match_query) - running_count = running_query.distinct().count() + running_query = self._running_jobs(now, name_match_query) + running_count = running_query.distinct().count() - available_query = self._available_jobs(now, name_match_query) - available_count = available_query.select(QueueItem.queue_name).distinct().count() + available_query = self._available_jobs(now, name_match_query) + available_count = available_query.select(QueueItem.queue_name).distinct().count() - available_not_running_query = self._available_jobs_not_running(now, name_match_query, - running_query) - available_not_running_count = (available_not_running_query.select(QueueItem.queue_name) - .distinct().count()) + available_not_running_query = self._available_jobs_not_running(now, name_match_query, + running_query) + available_not_running_count = (available_not_running_query.select(QueueItem.queue_name) + .distinct().count()) return (running_count, available_not_running_count, available_count)