~mediagoblin/mediagoblin

1c8d2b943b91b7ab01e2acf537a45f6cbf7a7025 — Ben Sturmfels 9 months ago 48ab691
Use newer celery `shared_task` API to support celery > 4.3
M mediagoblin/media_types/video/processing.py => mediagoblin/media_types/video/processing.py +3 -3
@@ 173,7 173,7 @@ def store_metadata(media_entry, metadata):
        media_entry.media_data_init(orig_metadata=stored_metadata)


@celery.task()
@celery.shared_task()
def main_task(entry_id, resolution, medium_size, **process_info):
    """
    Main celery task to transcode the video to the default resolution


@@ 197,7 197,7 @@ def main_task(entry_id, resolution, medium_size, **process_info):
    _log.debug('MediaEntry processed')


@celery.task()
@celery.shared_task()
def complementary_task(entry_id, resolution, medium_size, **process_info):
    """
    Side celery task to transcode the video to other resolutions


@@ 213,7 213,7 @@ def complementary_task(entry_id, resolution, medium_size, **process_info):
        entry.id, medium_size))


@celery.task()
@celery.shared_task()
def processing_cleanup(entry_id):
    _log.debug('Entered processing_cleanup')
    entry, manager = get_entry_and_processing_manager(entry_id)

M mediagoblin/notifications/task.py => mediagoblin/notifications/task.py +13 -17
@@ 16,8 16,7 @@

import logging

from celery import registry
from celery.task import Task
import celery

from mediagoblin.tools.mail import send_email
from mediagoblin.db.models import Notification


@@ 26,21 25,18 @@ from mediagoblin.db.models import Notification
_log = logging.getLogger(__name__)


class EmailNotificationTask(Task):
    '''
    Celery notification task.
@celery.shared_task()
def email_notification_task(notification_id, message):
    """Celery notification task.

    This task is executed by celeryd to offload long-running operations from
    the web server.
    '''
    def run(self, notification_id, message):
        cn = Notification.query.filter_by(id=notification_id).first()
        _log.info(f'Sending notification email about {cn}')

        return send_email(
            message['from'],
            [message['to']],
            message['subject'],
            message['body'])

email_notification_task = registry.tasks[EmailNotificationTask.name]
    """
    cn = Notification.query.filter_by(id=notification_id).first()
    _log.info(f'Sending notification email about {cn}')

    return send_email(
        message['from'],
        [message['to']],
        message['subject'],
        message['body'])

M mediagoblin/processing/task.py => mediagoblin/processing/task.py +1 -1
@@ 31,7 31,7 @@ logging.basicConfig()
_log.setLevel(logging.DEBUG)


@celery.task(default_retry_delay=2 * 60)
@celery.shared_task(default_retry_delay=2 * 60)
def handle_push_urls(feed_url):
    """Subtask, notifying the PuSH servers of new content


M mediagoblin/submit/task.py => mediagoblin/submit/task.py +1 -1
@@ 20,7 20,7 @@ import pytz

from mediagoblin.db.models import MediaEntry

@celery.task()
@celery.shared_task()
def collect_garbage():
    """
        Garbage collection to clean up media