diff --git a/data/queue.py b/data/queue.py index dbdaadb7d..303a2706a 100644 --- a/data/queue.py +++ b/data/queue.py @@ -276,29 +276,11 @@ class WorkQueue(object): """ Attempts to cancel the queue item with the given ID from the queue. Returns true on success and false if the queue item could not be canceled. """ - - with self._transaction_factory(db): - # Load the build queue item for update. - try: - queue_item = db_for_update(QueueItem.select() - .where(QueueItem.id == item_id)).get() - except QueueItem.DoesNotExist: - return False - - # Delete the queue item. - queue_item.delete_instance(recursive=True) - return True + count_removed = QueueItem.delete().where(QueueItem.id == item_id).execute() + return count_removed > 0 def complete(self, completed_item): - with self._transaction_factory(db): - try: - completed_item_obj = self._item_by_id_for_update(completed_item.id) - except QueueItem.DoesNotExist: - self._currently_processing = False - return - - completed_item_obj.delete_instance(recursive=True) - self._currently_processing = False + self._currently_processing = not self.cancel(completed_item.id) def incomplete(self, incomplete_item, retry_after=300, restore_retry=False): with self._transaction_factory(db):