This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/workers/diffsworker.py
Joseph Schorr ac0cca2d90 Switch to a unified worker system
- Handles logging
- Handles reporting to Sentry
- Removes old code around serving a web endpoint (unused now)
2015-07-28 17:26:12 -04:00

31 lines
926 B
Python

import logging
from app import image_diff_queue
from data import model
from endpoints.v1.registry import process_image_changes
from workers.queueworker import QueueWorker
logger = logging.getLogger(__name__)
class DiffsWorker(QueueWorker):
def process_queue_item(self, job_details):
image_id = job_details['image_id']
repository = job_details['repository']
namespace = model.user.get_namespace_by_user_id(job_details['namespace_user_id'])
try:
process_image_changes(namespace, repository, image_id)
except model.DataModelException:
# This exception is unrecoverable, and the item should continue and be
# marked as complete.
msg = ('Image does not exist in database \'%s\' for repo \'%s/\'%s\'' %
(image_id, namespace, repository))
logger.warning(msg)
return True
if __name__ == "__main__":
worker = DiffsWorker(image_diff_queue)
worker.start()