Revert change to queue

This commit is contained in:
Joseph Schorr 2015-08-05 15:27:33 -04:00
parent 48e5bd6613
commit d480a204f5

View file

@ -120,21 +120,16 @@ class WorkQueue(object):
name_match_query = self._name_match_query() name_match_query = self._name_match_query()
running = self._running_jobs(now, name_match_query) running = self._running_jobs(now, name_match_query)
avail = self._available_jobs_not_running(now, name_match_query, running).alias('avail') avail = self._available_jobs_not_running(now, name_match_query, running)
item = None item = None
try: try:
db_item_candidate_id = (QueueItem db_item_candidate = avail.order_by(QueueItem.id).get()
.select(avail.c.id)
.from_(avail)
.order_by(avail.c.id)
.tuples()
.get())[0]
with self._transaction_factory(db): with self._transaction_factory(db):
still_available_query = (db_for_update(self still_available_query = (db_for_update(self
._available_jobs(now, name_match_query) ._available_jobs(now, name_match_query)
.where(QueueItem.id == db_item_candidate_id))) .where(QueueItem.id == db_item_candidate.id)))
db_item = still_available_query.get() db_item = still_available_query.get()
db_item.available = False db_item.available = False