Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Attempt #2 to take care of some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pypt committed Oct 2, 2018
1 parent 7b80558 commit b89b525
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions mediacloud/mediawords/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid
from typing import Type, Any

from celery import Celery, Task
import celery
from kombu import Exchange, Queue

from mediawords.util.config import get_config as py_get_config
Expand All @@ -17,7 +17,7 @@ class McAbstractJobException(Exception):
pass


class _CeleryTask(Task):
class _CeleryTask(celery.Task):
"""Internal Celery task."""

__slots__ = [
Expand Down Expand Up @@ -47,13 +47,13 @@ class AbstractJob(object, metaclass=abc.ABCMeta):
"""Abstract job that concrete jobs should subclass and implement."""

@classmethod
@abc.abstractclassmethod
@abc.abstractmethod
def run_job(cls, *args, **kwargs) -> None:
"""Run job, raise on error."""
raise NotImplementedError("Abstract method.")

@classmethod
@abc.abstractclassmethod
@abc.abstractmethod
def queue_name(cls) -> str:
"""Return queue name."""
raise NotImplementedError("Abstract method.")
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self):
"""Constructor."""
self._task = _CeleryTask(job_class=self.__class__)

def celery_task(self) -> Task:
def celery_task(self) -> celery.Task:
"""(Internal) Return Celery task to be registered."""
return self._task

Expand All @@ -126,7 +126,7 @@ class McJobBrokerAppException(Exception):
pass


class JobBrokerApp(Celery):
class JobBrokerApp(celery.Celery):
"""Job broker class."""

__slots__ = [
Expand Down Expand Up @@ -180,7 +180,8 @@ def __init__(self, job_class: Type[AbstractJob]):
})
self.conf.task_queues = [queue]

def __route_task(name, args, kwargs, options, task=None, **kw):
# noinspection PyUnusedLocal
def __route_task(name, args_, kwargs_, options_, task_=None, **kw_):
return {'queue': name, 'exchange': name, 'routing_key': name}

self.conf.task_routes = (__route_task,)
Expand Down

0 comments on commit b89b525

Please sign in to comment.