Omer Katz 7 years ago
parent
commit
e6a6cced7f
100 changed files with 329 additions and 240 deletions
  1. 2 0
      celery/__main__.py
  2. 2 0
      celery/_state.py
  3. 1 3
      celery/app/amqp.py
  4. 1 0
      celery/app/annotations.py
  5. 3 1
      celery/app/backends.py
  6. 17 26
      celery/app/base.py
  7. 1 0
      celery/app/builtins.py
  8. 3 0
      celery/app/control.py
  9. 2 0
      celery/app/defaults.py
  10. 2 0
      celery/app/events.py
  11. 3 6
      celery/app/log.py
  12. 3 1
      celery/app/registry.py
  13. 3 0
      celery/app/routes.py
  14. 1 2
      celery/app/task.py
  15. 24 20
      celery/app/trace.py
  16. 3 6
      celery/app/utils.py
  17. 3 1
      celery/apps/beat.py
  18. 2 4
      celery/apps/multi.py
  19. 2 6
      celery/apps/worker.py
  20. 2 3
      celery/backends/amqp.py
  21. 0 1
      celery/backends/async.py
  22. 10 18
      celery/backends/base.py
  23. 4 0
      celery/backends/cache.py
  24. 4 0
      celery/backends/cassandra.py
  25. 4 1
      celery/backends/consul.py
  26. 5 0
      celery/backends/couchbase.py
  27. 4 0
      celery/backends/couchdb.py
  28. 5 2
      celery/backends/database/models.py
  29. 3 1
      celery/backends/database/session.py
  30. 6 2
      celery/backends/dynamodb.py
  31. 6 1
      celery/backends/elasticsearch.py
  32. 5 2
      celery/backends/filesystem.py
  33. 6 2
      celery/backends/mongodb.py
  34. 1 2
      celery/backends/redis.py
  35. 5 0
      celery/backends/riak.py
  36. 1 1
      celery/backends/rpc.py
  37. 7 11
      celery/beat.py
  38. 3 5
      celery/bin/amqp.py
  39. 7 13
      celery/bin/base.py
  40. 3 1
      celery/bin/beat.py
  41. 2 0
      celery/bin/call.py
  42. 6 10
      celery/bin/celery.py
  43. 4 2
      celery/bin/celeryd_detach.py
  44. 3 1
      celery/bin/control.py
  45. 3 1
      celery/bin/events.py
  46. 3 0
      celery/bin/graph.py
  47. 1 0
      celery/bin/list.py
  48. 2 0
      celery/bin/logtool.py
  49. 2 0
      celery/bin/migrate.py
  50. 3 0
      celery/bin/multi.py
  51. 2 1
      celery/bin/purge.py
  52. 1 0
      celery/bin/result.py
  53. 3 1
      celery/bin/shell.py
  54. 2 0
      celery/bin/upgrade.py
  55. 2 0
      celery/bin/worker.py
  56. 6 7
      celery/canvas.py
  57. 3 4
      celery/concurrency/asynpool.py
  58. 1 1
      celery/concurrency/base.py
  59. 7 5
      celery/concurrency/eventlet.py
  60. 3 0
      celery/concurrency/gevent.py
  61. 5 5
      celery/concurrency/prefork.py
  62. 2 0
      celery/concurrency/solo.py
  63. 1 0
      celery/contrib/abortable.py
  64. 1 2
      celery/contrib/migrate.py
  65. 4 1
      celery/contrib/pytest.py
  66. 3 0
      celery/contrib/rdb.py
  67. 3 1
      celery/contrib/sphinx.py
  68. 4 2
      celery/contrib/testing/app.py
  69. 0 1
      celery/contrib/testing/manager.py
  70. 2 0
      celery/contrib/testing/mocks.py
  71. 1 0
      celery/contrib/testing/tasks.py
  72. 3 1
      celery/contrib/testing/worker.py
  73. 2 4
      celery/events/cursesmon.py
  74. 0 1
      celery/events/dispatcher.py
  75. 2 0
      celery/events/dumper.py
  76. 2 0
      celery/events/event.py
  77. 0 1
      celery/events/receiver.py
  78. 3 1
      celery/events/snapshot.py
  79. 0 1
      celery/events/state.py
  80. 6 4
      celery/exceptions.py
  81. 3 0
      celery/five.py
  82. 3 5
      celery/fixups/django.py
  83. 1 0
      celery/loaders/app.py
  84. 2 4
      celery/loaders/base.py
  85. 3 0
      celery/loaders/default.py
  86. 2 0
      celery/local.py
  87. 3 4
      celery/platforms.py
  88. 3 6
      celery/result.py
  89. 2 5
      celery/schedules.py
  90. 4 0
      celery/security/certificate.py
  91. 2 0
      celery/security/key.py
  92. 3 3
      celery/security/serialization.py
  93. 3 0
      celery/security/utils.py
  94. 1 0
      celery/signals.py
  95. 4 1
      celery/task/base.py
  96. 2 0
      celery/utils/abstract.py
  97. 6 8
      celery/utils/collections.py
  98. 0 1
      celery/utils/debug.py
  99. 4 1
      celery/utils/deprecated.py
  100. 6 2
      celery/utils/dispatch/signal.py

+ 2 - 0
celery/__main__.py

@@ -1,6 +1,8 @@
 """Entry-point for the :program:`celery` umbrella command."""
 from __future__ import absolute_import, print_function, unicode_literals
+
 import sys
+
 from . import maybe_patch_concurrency
 
 __all__ = ('main',)

+ 2 - 0
celery/_state.py

@@ -7,10 +7,12 @@ like the ``current_app``, and ``current_task``.
 This module shouldn't be used directly.
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 import sys
 import threading
 import weakref
+
 from celery.local import Proxy
 from celery.utils.threads import LocalStack
 

+ 1 - 3
celery/app/amqp.py

@@ -4,13 +4,11 @@ from __future__ import absolute_import, unicode_literals
 
 import numbers
 import sys
-
 from collections import Mapping, namedtuple
 from datetime import timedelta
 from weakref import WeakValueDictionary
 
-from kombu import pools
-from kombu import Connection, Consumer, Exchange, Producer, Queue
+from kombu import Connection, Consumer, Exchange, Producer, Queue, pools
 from kombu.common import Broadcast
 from kombu.utils.functional import maybe_list
 from kombu.utils.objects import cached_property

+ 1 - 0
celery/app/annotations.py

@@ -8,6 +8,7 @@ This prepares and performs the annotations in the
 :setting:`task_annotations` setting.
 """
 from __future__ import absolute_import, unicode_literals
+
 from celery.five import string_t
 from celery.utils.functional import firstmethod, mlazy
 from celery.utils.imports import instantiate

+ 3 - 1
celery/app/backends.py

@@ -1,10 +1,12 @@
 # -*- coding: utf-8 -*-
 """Backend selection."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
 import types
-from celery.exceptions import ImproperlyConfigured
+
 from celery._state import current_app
+from celery.exceptions import ImproperlyConfigured
 from celery.five import reraise
 from celery.utils.imports import load_extension_class_names, symbol_by_name
 

+ 17 - 26
celery/app/base.py

@@ -2,12 +2,11 @@
 """Actual App instance implementation."""
 from __future__ import absolute_import, unicode_literals
 
-from datetime import datetime
 import os
 import threading
 import warnings
-
 from collections import defaultdict, deque
+from datetime import datetime
 from operator import attrgetter
 
 from kombu import pools
@@ -19,43 +18,35 @@ from kombu.utils.uuid import uuid
 from vine import starpromise
 from vine.utils import wraps
 
-from celery import platforms
-from celery import signals
-from celery._state import (
-    _task_stack, get_current_app, _set_current_app, set_default_app,
-    _register_app, _deregister_app,
-    get_current_worker_task, connect_on_app_finalize,
-    _announce_app_finalized,
-)
+from celery import platforms, signals
+from celery._state import (_announce_app_finalized, _deregister_app,
+                           _register_app, _set_current_app, _task_stack,
+                           connect_on_app_finalize, get_current_app,
+                           get_current_worker_task, set_default_app)
 from celery.exceptions import AlwaysEagerIgnored, ImproperlyConfigured
-from celery.five import (
-    UserDict, bytes_if_py2, python_2_unicode_compatible, values,
-)
+from celery.five import (UserDict, bytes_if_py2, python_2_unicode_compatible,
+                         values)
 from celery.loaders import get_loader_cls
 from celery.local import PromiseProxy, maybe_evaluate
 from celery.utils import abstract
 from celery.utils.collections import AttributeDictMixin
 from celery.utils.dispatch import Signal
-from celery.utils.functional import first, maybe_list, head_from_fun
-from celery.utils.time import timezone, \
-    get_exponential_backoff_interval, to_utc
+from celery.utils.functional import first, head_from_fun, maybe_list
 from celery.utils.imports import gen_task_name, instantiate, symbol_by_name
 from celery.utils.log import get_logger
 from celery.utils.objects import FallbackContext, mro_lookup
+from celery.utils.time import (get_exponential_backoff_interval, timezone,
+                               to_utc)
 
-from .annotations import prepare as prepare_annotations
+# Load all builtin tasks
+from . import builtins  # noqa
 from . import backends
+from .annotations import prepare as prepare_annotations
 from .defaults import find_deprecated_settings
 from .registry import TaskRegistry
-from .utils import (
-    AppPickler, Settings,
-    bugreport, _unpickle_app, _unpickle_app_v2,
-    _old_key_to_new, _new_key_to_old,
-    appstr, detect_settings,
-)
-
-# Load all builtin tasks
-from . import builtins  # noqa
+from .utils import (AppPickler, Settings, _new_key_to_old, _old_key_to_new,
+                    _unpickle_app, _unpickle_app_v2, appstr, bugreport,
+                    detect_settings)
 
 __all__ = ('Celery',)
 

+ 1 - 0
celery/app/builtins.py

@@ -4,6 +4,7 @@
 The built-in tasks are always available in all app instances.
 """
 from __future__ import absolute_import, unicode_literals
+
 from celery._state import connect_on_app_finalize
 from celery.utils.log import get_logger
 

+ 3 - 0
celery/app/control.py

@@ -5,11 +5,14 @@ Client for worker remote control commands.
 Server implementation is in :mod:`celery.worker.control`.
 """
 from __future__ import absolute_import, unicode_literals
+
 import warnings
+
 from billiard.common import TERM_SIGNAME
 from kombu.pidbox import Mailbox
 from kombu.utils.functional import lazy
 from kombu.utils.objects import cached_property
+
 from celery.exceptions import DuplicateNodenameWarning
 from celery.utils.text import pluralize
 

+ 2 - 0
celery/app/defaults.py

@@ -1,9 +1,11 @@
 # -*- coding: utf-8 -*-
 """Configuration introspection and defaults."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
 from collections import deque, namedtuple
 from datetime import timedelta
+
 from celery.five import items, keys, python_2_unicode_compatible
 from celery.utils.functional import memoize
 from celery.utils.serialization import strtobool

+ 2 - 0
celery/app/events.py

@@ -1,6 +1,8 @@
 """Implementation for the app.events shortcuts."""
 from __future__ import absolute_import, unicode_literals
+
 from contextlib import contextmanager
+
 from kombu.utils.objects import cached_property
 
 

+ 3 - 6
celery/app/log.py

@@ -12,7 +12,6 @@ from __future__ import absolute_import, unicode_literals
 import logging
 import os
 import sys
-
 from logging.handlers import WatchedFileHandler
 
 from kombu.utils.encoding import set_default_encoding_file
@@ -22,11 +21,9 @@ from celery._state import get_current_task
 from celery.five import string_t
 from celery.local import class_property
 from celery.platforms import isatty
-from celery.utils.log import (
-    get_logger, mlevel,
-    ColorFormatter, LoggingProxy, get_multiprocessing_logger,
-    reset_multiprocessing_logger,
-)
+from celery.utils.log import (ColorFormatter, LoggingProxy, get_logger,
+                              get_multiprocessing_logger, mlevel,
+                              reset_multiprocessing_logger)
 from celery.utils.nodenames import node_format
 from celery.utils.term import colored
 

+ 3 - 1
celery/app/registry.py

@@ -1,10 +1,12 @@
 # -*- coding: utf-8 -*-
 """Registry of available tasks."""
 from __future__ import absolute_import, unicode_literals
+
 import inspect
 from importlib import import_module
+
 from celery._state import get_current_app
-from celery.exceptions import NotRegistered, InvalidTaskError
+from celery.exceptions import InvalidTaskError, NotRegistered
 from celery.five import items
 
 __all__ = ('TaskRegistry',)

+ 3 - 0
celery/app/routes.py

@@ -4,10 +4,13 @@
 Contains utilities for working with task routers, (:setting:`task_routes`).
 """
 from __future__ import absolute_import, unicode_literals
+
 import re
 import string
 from collections import Mapping, OrderedDict
+
 from kombu import Queue
+
 from celery.exceptions import QueueNotFound
 from celery.five import items, string_t
 from celery.utils.collections import lpmerge

+ 1 - 2
celery/app/task.py

@@ -8,8 +8,7 @@ from billiard.einfo import ExceptionInfo
 from kombu.exceptions import OperationalError
 from kombu.utils.uuid import uuid
 
-from celery import current_app, group
-from celery import states
+from celery import current_app, group, states
 from celery._state import _task_stack
 from celery.canvas import signature
 from celery.exceptions import Ignore, MaxRetriesExceededError, Reject, Retry

+ 24 - 20
celery/app/trace.py

@@ -6,42 +6,46 @@ errors are recorded, handlers are applied and so on.
 """
 from __future__ import absolute_import, unicode_literals
 
-# ## ---
-# This is the heart of the worker, the inner loop so to speak.
-# It used to be split up into nice little classes and methods,
-# but in the end it only resulted in bad performance and horrible tracebacks,
-# so instead we now use one closure per task class.
-
-# pylint: disable=redefined-outer-name
-# We cache globals and attribute lookups, so disable this warning.
-# pylint: disable=broad-except
-# We know what we're doing...
-
 import logging
 import os
 import sys
-
 from collections import namedtuple
 from warnings import warn
 
 from billiard.einfo import ExceptionInfo
 from kombu.exceptions import EncodeError
-from kombu.serialization import loads as loads_message, prepare_accept_content
+from kombu.serialization import loads as loads_message
+from kombu.serialization import prepare_accept_content
 from kombu.utils.encoding import safe_repr, safe_str
 
-from celery import current_app, group
-from celery import states, signals
+from celery import current_app, group, signals, states
 from celery._state import _task_stack
-from celery.app.task import Task as BaseTask, Context
-from celery.exceptions import Ignore, Reject, Retry, InvalidTaskError
+from celery.app.task import Task as BaseTask
+from celery.app.task import Context
+from celery.exceptions import Ignore, InvalidTaskError, Reject, Retry
 from celery.five import monotonic, text_t
 from celery.utils.log import get_logger
 from celery.utils.nodenames import gethostname
 from celery.utils.objects import mro_lookup
 from celery.utils.saferepr import saferepr
-from celery.utils.serialization import (
-    get_pickleable_exception, get_pickled_exception, get_pickleable_etype,
-)
+from celery.utils.serialization import (get_pickleable_etype,
+                                        get_pickleable_exception,
+                                        get_pickled_exception)
+
+# ## ---
+# This is the heart of the worker, the inner loop so to speak.
+# It used to be split up into nice little classes and methods,
+# but in the end it only resulted in bad performance and horrible tracebacks,
+# so instead we now use one closure per task class.
+
+# pylint: disable=redefined-outer-name
+# We cache globals and attribute lookups, so disable this warning.
+# pylint: disable=broad-except
+# We know what we're doing...
+
+
+
+
 
 __all__ = (
     'TraceInfo', 'build_tracer', 'trace_task',

+ 3 - 6
celery/app/utils.py

@@ -5,7 +5,6 @@ from __future__ import absolute_import, unicode_literals
 import os
 import platform as _platform
 import re
-
 from collections import Mapping, namedtuple
 from copy import deepcopy
 from types import ModuleType
@@ -16,13 +15,11 @@ from celery.exceptions import ImproperlyConfigured
 from celery.five import items, keys, string_t, values
 from celery.platforms import pyimplementation
 from celery.utils.collections import ConfigurationView
+from celery.utils.imports import import_from_cwd, qualname, symbol_by_name
 from celery.utils.text import pretty
-from celery.utils.imports import import_from_cwd, symbol_by_name, qualname
 
-from .defaults import (
-    _TO_NEW_KEY, _TO_OLD_KEY, _OLD_DEFAULTS, _OLD_SETTING_KEYS,
-    DEFAULTS, SETTING_KEYS, find,
-)
+from .defaults import (_OLD_DEFAULTS, _OLD_SETTING_KEYS, _TO_NEW_KEY,
+                       _TO_OLD_KEY, DEFAULTS, SETTING_KEYS, find)
 
 __all__ = (
     'Settings', 'appstr', 'bugreport',

+ 3 - 1
celery/apps/beat.py

@@ -8,11 +8,13 @@ as an actual application, like installing signal handlers
 and so on.
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 import numbers
 import socket
 import sys
 from datetime import datetime
-from celery import VERSION_BANNER, platforms, beat
+
+from celery import VERSION_BANNER, beat, platforms
 from celery.five import text_t
 from celery.utils.imports import qualname
 from celery.utils.log import LOG_LEVELS, get_logger

+ 2 - 4
celery/apps/multi.py

@@ -6,7 +6,6 @@ import os
 import shlex
 import signal
 import sys
-
 from collections import OrderedDict, defaultdict
 from functools import partial
 from subprocess import Popen
@@ -17,9 +16,8 @@ from kombu.utils.objects import cached_property
 
 from celery.five import UserList, items
 from celery.platforms import IS_WINDOWS, Pidfile, signal_name
-from celery.utils.nodenames import (
-    gethostname, host_format, node_format, nodesplit,
-)
+from celery.utils.nodenames import (gethostname, host_format, node_format,
+                                    nodesplit)
 from celery.utils.saferepr import saferepr
 
 __all__ = ('Cluster', 'Node')

+ 2 - 6
celery/apps/worker.py

@@ -13,23 +13,19 @@ import logging
 import os
 import platform as _platform
 import sys
-
 from datetime import datetime
 from functools import partial
 
 from billiard.process import current_process
 from kombu.utils.encoding import safe_str
 
-from celery import VERSION_BANNER
-from celery import platforms
-from celery import signals
+from celery import VERSION_BANNER, platforms, signals
 from celery.app import trace
 from celery.exceptions import WorkerShutdown, WorkerTerminate
 from celery.five import string, string_t
 from celery.loaders.app import AppLoader
 from celery.platforms import EX_FAILURE, EX_OK, check_privileges, isatty
-from celery.utils import static
-from celery.utils import term
+from celery.utils import static, term
 from celery.utils.debug import cry
 from celery.utils.imports import qualname
 from celery.utils.log import get_logger, in_sighandler, set_in_sighandler

+ 2 - 3
celery/backends/amqp.py

@@ -3,15 +3,14 @@
 from __future__ import absolute_import, unicode_literals
 
 import socket
-
 from collections import deque
 from operator import itemgetter
 
-from kombu import Exchange, Queue, Producer, Consumer
+from kombu import Consumer, Exchange, Producer, Queue
 
 from celery import states
 from celery.exceptions import TimeoutError
-from celery.five import range, monotonic
+from celery.five import monotonic, range
 from celery.utils import deprecated
 from celery.utils.log import get_logger
 

+ 0 - 1
celery/backends/async.py

@@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals
 
 import socket
 import threading
-
 from collections import deque
 from time import sleep
 from weakref import WeakKeyDictionary

+ 10 - 18
celery/backends/base.py

@@ -10,37 +10,29 @@ from __future__ import absolute_import, unicode_literals
 
 import sys
 import time
-
 from collections import namedtuple
 from datetime import timedelta
 from weakref import WeakValueDictionary
 
 from billiard.einfo import ExceptionInfo
-from kombu.serialization import (
-    dumps, loads, prepare_accept_content,
-    registry as serializer_registry,
-)
+from kombu.serialization import registry as serializer_registry
+from kombu.serialization import dumps, loads, prepare_accept_content
 from kombu.utils.encoding import bytes_to_str, ensure_bytes, from_utf8
 from kombu.utils.url import maybe_sanitize_url
 
-from celery import states
-from celery import current_app, group, maybe_signature
+from celery import current_app, group, maybe_signature, states
 from celery._state import get_current_task
-from celery.exceptions import (
-    ChordError, TimeoutError, TaskRevokedError, ImproperlyConfigured,
-)
+from celery.exceptions import (ChordError, ImproperlyConfigured,
+                               TaskRevokedError, TimeoutError)
 from celery.five import items
-from celery.result import (
-    GroupResult, ResultBase, allow_join_result, result_from_tuple,
-)
+from celery.result import (GroupResult, ResultBase, allow_join_result,
+                           result_from_tuple)
 from celery.utils.collections import BufferMap
 from celery.utils.functional import LRUCache, arity_greater
 from celery.utils.log import get_logger
-from celery.utils.serialization import (
-    get_pickled_exception,
-    get_pickleable_exception,
-    create_exception_cls,
-)
+from celery.utils.serialization import (create_exception_cls,
+                                        get_pickleable_exception,
+                                        get_pickled_exception)
 
 __all__ = ('BaseBackend', 'KeyValueStoreBackend', 'DisabledBackend')
 

+ 4 - 0
celery/backends/cache.py

@@ -1,11 +1,15 @@
 # -*- coding: utf-8 -*-
 """Memcached and in-memory cache result backend."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
 from kombu.utils.encoding import bytes_to_str, ensure_bytes
 from kombu.utils.objects import cached_property
+
 from celery.exceptions import ImproperlyConfigured
 from celery.utils.functional import LRUCache
+
 from .base import KeyValueStoreBackend
 
 __all__ = ('CacheBackend',)

+ 4 - 0
celery/backends/cassandra.py

@@ -1,11 +1,15 @@
 # -* coding: utf-8 -*-
 """Apache Cassandra result store backend using the DataStax driver."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
 from celery import states
 from celery.exceptions import ImproperlyConfigured
 from celery.utils.log import get_logger
+
 from .base import BaseBackend
+
 try:  # pragma: no cover
     import cassandra
     import cassandra.auth

+ 4 - 1
celery/backends/consul.py

@@ -5,10 +5,13 @@
     in the key-value store of Consul.
 """
 from __future__ import absolute_import, unicode_literals
+
 from kombu.utils.url import parse_url
+
+from celery.backends.base import PY3, KeyValueStoreBackend
 from celery.exceptions import ImproperlyConfigured
-from celery.backends.base import KeyValueStoreBackend, PY3
 from celery.utils.log import get_logger
+
 try:
     import consul
 except ImportError:

+ 5 - 0
celery/backends/couchbase.py

@@ -1,11 +1,16 @@
 # -*- coding: utf-8 -*-
 """Couchbase result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 import logging
+
 from kombu.utils.encoding import str_t
 from kombu.utils.url import _parse_url
+
 from celery.exceptions import ImproperlyConfigured
+
 from .base import KeyValueStoreBackend
+
 try:
     from couchbase import Couchbase
     from couchbase.connection import Connection

+ 4 - 0
celery/backends/couchdb.py

@@ -1,9 +1,13 @@
 # -*- coding: utf-8 -*-
 """CouchDB result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 from kombu.utils.url import _parse_url
+
 from celery.exceptions import ImproperlyConfigured
+
 from .base import KeyValueStoreBackend
+
 try:
     import pycouchdb
 except ImportError:

+ 5 - 2
celery/backends/database/models.py

@@ -1,11 +1,14 @@
 # -*- coding: utf-8 -*-
 """Database models used by the SQLAlchemy result store backend."""
 from __future__ import absolute_import, unicode_literals
-import sqlalchemy as sa
+
 from datetime import datetime
-from sqlalchemy.types import PickleType
+
+import sqlalchemy as sa
 from celery import states
 from celery.five import python_2_unicode_compatible
+from sqlalchemy.types import PickleType
+
 from .session import ResultModelBase
 
 __all__ = ('Task', 'TaskSet')

+ 3 - 1
celery/backends/database/session.py

@@ -1,11 +1,13 @@
 # -*- coding: utf-8 -*-
 """SQLAlchemy session."""
 from __future__ import absolute_import, unicode_literals
+
+from kombu.utils.compat import register_after_fork
+
 from sqlalchemy import create_engine
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.orm import sessionmaker
 from sqlalchemy.pool import NullPool
-from kombu.utils.compat import register_after_fork
 
 ResultModelBase = declarative_base()
 

+ 6 - 2
celery/backends/dynamodb.py

@@ -1,14 +1,18 @@
 # -*- coding: utf-8 -*-
 """AWS DynamoDB result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 from collections import namedtuple
-from time import time, sleep
+from time import sleep, time
 
 from kombu.utils.url import _parse_url as parse_url
+
 from celery.exceptions import ImproperlyConfigured
-from celery.utils.log import get_logger
 from celery.five import string
+from celery.utils.log import get_logger
+
 from .base import KeyValueStoreBackend
+
 try:
     import boto3
     from botocore.exceptions import ClientError

+ 6 - 1
celery/backends/elasticsearch.py

@@ -1,12 +1,17 @@
 # -* coding: utf-8 -*-
 """Elasticsearch result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 from datetime import datetime
-from kombu.utils.url import _parse_url
+
 from kombu.utils.encoding import bytes_to_str
+from kombu.utils.url import _parse_url
+
 from celery.exceptions import ImproperlyConfigured
 from celery.five import items
+
 from .base import KeyValueStoreBackend
+
 try:
     import elasticsearch
 except ImportError:

+ 5 - 2
celery/backends/filesystem.py

@@ -1,12 +1,15 @@
 # -*- coding: utf-8 -*-
 """File-system result store backend."""
 from __future__ import absolute_import, unicode_literals
-import os
+
 import locale
+import os
+
 from kombu.utils.encoding import ensure_bytes
+
 from celery import uuid
-from celery.exceptions import ImproperlyConfigured
 from celery.backends.base import KeyValueStoreBackend
+from celery.exceptions import ImproperlyConfigured
 
 # Python 2 does not have FileNotFoundError and IsADirectoryError
 try:

+ 6 - 2
celery/backends/mongodb.py

@@ -1,13 +1,17 @@
 # -*- coding: utf-8 -*-
 """MongoDB result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 from datetime import datetime, timedelta
+
+from kombu.exceptions import EncodeError
 from kombu.utils.objects import cached_property
 from kombu.utils.url import maybe_sanitize_url
-from kombu.exceptions import EncodeError
+
 from celery import states
 from celery.exceptions import ImproperlyConfigured
-from celery.five import string_t, items
+from celery.five import items, string_t
+
 from .base import BaseBackend
 
 try:

+ 1 - 2
celery/backends/redis.py

@@ -18,8 +18,7 @@ from celery.utils.functional import dictfilter
 from celery.utils.log import get_logger
 from celery.utils.time import humanize_seconds
 
-from . import async
-from . import base
+from . import async, base
 
 try:
     import redis

+ 5 - 0
celery/backends/riak.py

@@ -1,10 +1,15 @@
 # -*- coding: utf-8 -*-
 """Riak result store backend."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
 from kombu.utils.url import _parse_url
+
 from celery.exceptions import ImproperlyConfigured
+
 from .base import KeyValueStoreBackend
+
 try:
     import riak
     from riak import RiakClient

+ 1 - 1
celery/backends/rpc.py

@@ -5,9 +5,9 @@ RPC-style result backend, using reply-to and one queue per client.
 """
 from __future__ import absolute_import, unicode_literals
 
-import kombu
 import time
 
+import kombu
 from kombu.common import maybe_declare
 from kombu.utils.compat import register_after_fork
 from kombu.utils.objects import cached_property

+ 7 - 11
celery/beat.py

@@ -6,31 +6,27 @@ import copy
 import errno
 import heapq
 import os
-import time
 import shelve
 import sys
+import time
 import traceback
-
 from collections import namedtuple
 from functools import total_ordering
 from threading import Event, Thread
 
 from billiard import ensure_multiprocessing
-from billiard.context import Process
 from billiard.common import reset_signals
+from billiard.context import Process
 from kombu.utils.functional import maybe_evaluate, reprcall
 from kombu.utils.objects import cached_property
 
-from . import __version__
-from . import platforms
-from . import signals
-from .five import (
-    items, monotonic, python_2_unicode_compatible, reraise, values,
-)
-from .schedules import maybe_schedule, crontab
+from . import __version__, platforms, signals
+from .five import (items, monotonic, python_2_unicode_compatible, reraise,
+                   values)
+from .schedules import crontab, maybe_schedule
 from .utils.imports import load_extension_class_names, symbol_by_name
-from .utils.time import humanize_seconds
 from .utils.log import get_logger, iter_open_logger_fds
+from .utils.time import humanize_seconds
 
 __all__ = (
     'SchedulingError', 'ScheduleEntry', 'Scheduler',

+ 3 - 5
celery/bin/amqp.py

@@ -6,19 +6,17 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import cmd as _cmd
-import sys
-import shlex
 import pprint
-
+import shlex
+import sys
 from functools import partial
 from itertools import count
 
 from kombu.utils.encoding import safe_str
 
-from celery.utils.functional import padlist
-
 from celery.bin.base import Command
 from celery.five import string_t
+from celery.utils.functional import padlist
 from celery.utils.serialization import strtobool
 
 __all__ = ('AMQPAdmin', 'AMQShell', 'Spec', 'amqp')

+ 7 - 13
celery/bin/base.py

@@ -3,33 +3,27 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import argparse
+import json
 import os
 import random
 import re
 import sys
 import warnings
-import json
-
 from collections import defaultdict
 from heapq import heappush
 from pprint import pformat
 
-from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
-from celery import signals
+from celery import VERSION_BANNER, Celery, maybe_patch_concurrency, signals
 from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning
-from celery.five import (
-    getfullargspec, items, python_2_unicode_compatible,
-    string, string_t, text_t, long_t,
-)
+from celery.five import (getfullargspec, items, long_t,
+                         python_2_unicode_compatible, string, string_t,
+                         text_t)
 from celery.platforms import EX_FAILURE, EX_OK, EX_USAGE, isatty
-from celery.utils import imports
-from celery.utils import term
-from celery.utils import text
+from celery.utils import imports, term, text
 from celery.utils.functional import dictfilter
-from celery.utils.nodenames import node_format, host_format
+from celery.utils.nodenames import host_format, node_format
 from celery.utils.objects import Bunch
 
-
 # Option is here for backwards compatiblity, as third-party commands
 # may import it from here.
 try:

+ 3 - 1
celery/bin/beat.py

@@ -65,9 +65,11 @@
     Executable to use for the detached process.
 """
 from __future__ import absolute_import, unicode_literals
+
 from functools import partial
-from celery.platforms import detached, maybe_drop_privileges
+
 from celery.bin.base import Command, daemon_options
+from celery.platforms import detached, maybe_drop_privileges
 
 __all__ = ('beat',)
 

+ 2 - 0
celery/bin/call.py

@@ -1,6 +1,8 @@
 """The ``celery call`` program used to send tasks from the command-line."""
 from __future__ import absolute_import, unicode_literals
+
 from kombu.utils.json import loads
+
 from celery.bin.base import Command
 from celery.five import string_t
 from celery.utils.time import maybe_iso8601

+ 6 - 10
celery/bin/celery.py

@@ -253,22 +253,16 @@ in any command that also has a `--detach` option.
 
     Destination routing key (defaults to the queue routing key).
 """
-from __future__ import absolute_import, unicode_literals, print_function
+from __future__ import absolute_import, print_function, unicode_literals
 
 import numbers
 import sys
-
 from functools import partial
 
-from celery.platforms import EX_OK, EX_FAILURE, EX_USAGE
-from celery.utils import term
-from celery.utils import text
-
-# Cannot use relative imports here due to a Windows issue (#1111).
-from celery.bin.base import Command, Extensions
-
 # Import commands from other modules
 from celery.bin.amqp import amqp
+# Cannot use relative imports here due to a Windows issue (#1111).
+from celery.bin.base import Command, Extensions
 from celery.bin.beat import beat
 from celery.bin.call import call
 from celery.bin.control import _RemoteControl  # noqa
@@ -281,8 +275,10 @@ from celery.bin.migrate import migrate
 from celery.bin.purge import purge
 from celery.bin.result import result
 from celery.bin.shell import shell
-from celery.bin.worker import worker
 from celery.bin.upgrade import upgrade
+from celery.bin.worker import worker
+from celery.platforms import EX_FAILURE, EX_OK, EX_USAGE
+from celery.utils import term, text
 
 __all__ = ('CeleryCommand', 'main')
 

+ 4 - 2
celery/bin/celeryd_detach.py

@@ -6,14 +6,16 @@ leads to weird issues (it was a long time ago now, but it
 could have something to do with the threading mutex bug)
 """
 from __future__ import absolute_import, unicode_literals
+
 import argparse
-import celery
 import os
 import sys
+
+import celery
+from celery.bin.base import daemon_options
 from celery.platforms import EX_FAILURE, detached
 from celery.utils.log import get_logger
 from celery.utils.nodenames import default_nodename, node_format
-from celery.bin.base import daemon_options
 
 __all__ = ('detached_celeryd', 'detach')
 

+ 3 - 1
celery/bin/control.py

@@ -1,9 +1,11 @@
 """The ``celery control``, ``. inspect`` and ``. status`` programs."""
 from __future__ import absolute_import, unicode_literals
+
 from kombu.utils.json import dumps
 from kombu.utils.objects import cached_property
-from celery.five import items, string_t
+
 from celery.bin.base import Command
+from celery.five import items, string_t
 from celery.platforms import EX_UNAVAILABLE, EX_USAGE
 from celery.utils import text
 

+ 3 - 1
celery/bin/events.py

@@ -66,10 +66,12 @@
     Executable to use for the detached process.
 """
 from __future__ import absolute_import, unicode_literals
+
 import sys
 from functools import partial
-from celery.platforms import detached, set_process_title, strargv
+
 from celery.bin.base import Command, daemon_options
+from celery.platforms import detached, set_process_title, strargv
 
 __all__ = ('events',)
 

+ 3 - 0
celery/bin/graph.py

@@ -4,9 +4,12 @@
 .. program:: celery graph
 """
 from __future__ import absolute_import, unicode_literals
+
 from operator import itemgetter
+
 from celery.five import items, python_2_unicode_compatible
 from celery.utils.graph import DependencyGraph, GraphFormatter
+
 from .base import Command
 
 __all__ = ('graph',)

+ 1 - 0
celery/bin/list.py

@@ -1,5 +1,6 @@
 """The ``celery list bindings`` command, used to inspect queue bindings."""
 from __future__ import absolute_import, unicode_literals
+
 from celery.bin.base import Command
 
 

+ 2 - 0
celery/bin/logtool.py

@@ -5,9 +5,11 @@
 """
 
 from __future__ import absolute_import, unicode_literals
+
 import re
 from collections import Counter
 from fileinput import FileInput
+
 from .base import Command
 
 __all__ = ('logtool',)

+ 2 - 0
celery/bin/migrate.py

@@ -1,7 +1,9 @@
 """The ``celery migrate`` command, used to filter and move messages."""
 from __future__ import absolute_import, unicode_literals
+
 from celery.bin.base import Command
 
+
 MIGRATE_PROGRESS_FMT = """\
 Migrating task {state.count}/{state.strtotal}: \
 {body[task]}[{body[id]}]\

+ 3 - 0
celery/bin/multi.py

@@ -94,11 +94,14 @@ Examples
     celery worker -n xuzzy@myhost -c 3
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 import os
 import signal
 import sys
 from functools import wraps
+
 from kombu.utils.objects import cached_property
+
 from celery import VERSION_BANNER
 from celery.apps.multi import Cluster, MultiParser, NamespacedOptionParser
 from celery.platforms import EX_FAILURE, EX_OK, signals

+ 2 - 1
celery/bin/purge.py

@@ -1,7 +1,8 @@
 """The ``celery purge`` program, used to delete messages from queues."""
 from __future__ import absolute_import, unicode_literals
-from celery.five import keys
+
 from celery.bin.base import Command
+from celery.five import keys
 from celery.utils import text
 
 

+ 1 - 0
celery/bin/result.py

@@ -1,5 +1,6 @@
 """The ``celery result`` program, used to inspect task results."""
 from __future__ import absolute_import, unicode_literals
+
 from celery.bin.base import Command
 
 

+ 3 - 1
celery/bin/shell.py

@@ -1,10 +1,12 @@
 """The ``celery shell`` program, used to start a REPL."""
 from __future__ import absolute_import, unicode_literals
+
 import os
 import sys
 from importlib import import_module
-from celery.five import values
+
 from celery.bin.base import Command
+from celery.five import values
 
 
 class shell(Command):  # pragma: no cover

+ 2 - 0
celery/bin/upgrade.py

@@ -1,6 +1,8 @@
 """The ``celery upgrade`` command, used to upgrade from previous versions."""
 from __future__ import absolute_import, print_function, unicode_literals
+
 import codecs
+
 from celery.app import defaults
 from celery.bin.base import Command
 from celery.utils.functional import pass1

+ 2 - 0
celery/bin/worker.py

@@ -176,7 +176,9 @@ The :program:`celery worker` command (previously known as ``celeryd``)
     Executable to use for the detached process.
 """
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
 from celery import concurrency
 from celery.bin.base import Command, daemon_options
 from celery.bin.celeryd_detach import detached_celeryd

+ 6 - 7
celery/canvas.py

@@ -10,10 +10,10 @@ from __future__ import absolute_import, unicode_literals
 import itertools
 import operator
 import sys
-
 from collections import MutableSequence, deque
 from copy import deepcopy
-from functools import partial as _partial, reduce
+from functools import partial as _partial
+from functools import reduce
 from operator import itemgetter
 
 from kombu.utils.functional import fxrange, reprcall
@@ -26,12 +26,11 @@ from celery.five import python_2_unicode_compatible
 from celery.local import try_import
 from celery.result import GroupResult
 from celery.utils import abstract
-from celery.utils.functional import (
-    maybe_list, is_list, _regen, regen, chunks as _chunks,
-    seq_concat_seq, seq_concat_item,
-)
+from celery.utils.functional import chunks as _chunks
+from celery.utils.functional import (_regen, is_list, maybe_list, regen,
+                                     seq_concat_item, seq_concat_seq)
 from celery.utils.objects import getitem_property
-from celery.utils.text import truncate, remove_repeating_from_task
+from celery.utils.text import remove_repeating_from_task, truncate
 
 __all__ = (
     'Signature', 'chain', 'xmap', 'xstarmap', 'chunks',

+ 3 - 4
celery/concurrency/asynpool.py

@@ -23,7 +23,6 @@ import socket
 import struct
 import sys
 import time
-
 from collections import deque, namedtuple
 from io import BytesIO
 from numbers import Integral
@@ -31,11 +30,11 @@ from pickle import HIGHEST_PROTOCOL
 from time import sleep
 from weakref import WeakValueDictionary, ref
 
-from billiard.pool import RUN, TERMINATE, ACK, NACK, WorkersJoined
 from billiard import pool as _pool
-from billiard.compat import buf_t, setblocking, isblocking
+from billiard.compat import buf_t, isblocking, setblocking
+from billiard.pool import ACK, NACK, RUN, TERMINATE, WorkersJoined
 from billiard.queues import _SimpleQueue
-from kombu.async import WRITE, ERR
+from kombu.async import ERR, WRITE
 from kombu.serialization import pickle as _pickle
 from kombu.utils.eventio import SELECT_BAD_FD
 from kombu.utils.functional import fxrange

+ 1 - 1
celery/concurrency/base.py

@@ -13,8 +13,8 @@ from kombu.utils.encoding import safe_repr
 from celery.exceptions import WorkerShutdown, WorkerTerminate
 from celery.five import monotonic, reraise
 from celery.utils import timer2
-from celery.utils.text import truncate
 from celery.utils.log import get_logger
+from celery.utils.text import truncate
 
 __all__ = ('BasePool', 'apply_target')
 

+ 7 - 5
celery/concurrency/eventlet.py

@@ -1,9 +1,16 @@
 # -*- coding: utf-8 -*-
 """Eventlet execution pool."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
+from kombu.async import timer as _timer  # noqa
 from kombu.five import monotonic
 
+from celery import signals  # noqa
+
+from . import base  # noqa
+
 __all__ = ('TaskPool',)
 
 W_RACE = """\
@@ -20,13 +27,8 @@ for mod in (mod for mod in sys.modules if mod.startswith(RACE_MODS)):
             import warnings
             warnings.warn(RuntimeWarning(W_RACE % side))
 
-# idiotic pep8.py does not allow expressions before imports
-# so have to silence errors here
-from kombu.async import timer as _timer  # noqa
 
-from celery import signals  # noqa
 
-from . import base  # noqa
 
 
 def apply_target(target, args=(), kwargs={}, callback=None,

+ 3 - 0
celery/concurrency/gevent.py

@@ -1,9 +1,12 @@
 # -*- coding: utf-8 -*-
 """Gevent execution pool."""
 from __future__ import absolute_import, unicode_literals
+
 from kombu.async import timer as _timer
 from kombu.five import monotonic
+
 from . import base
+
 try:
     from gevent import Timeout
 except ImportError:  # pragma: no cover

+ 5 - 5
celery/concurrency/prefork.py

@@ -7,13 +7,13 @@ from __future__ import absolute_import, unicode_literals
 
 import os
 
-from billiard.common import REMAP_SIGTERM, TERM_SIGNAME
 from billiard import forking_enable
-from billiard.pool import RUN, CLOSE, Pool as BlockingPool
+from billiard.common import REMAP_SIGTERM, TERM_SIGNAME
+from billiard.pool import Pool as BlockingPool
+from billiard.pool import CLOSE, RUN
 
-from celery import platforms
-from celery import signals
-from celery._state import set_default_app, _set_task_join_will_block
+from celery import platforms, signals
+from celery._state import _set_task_join_will_block, set_default_app
 from celery.app import trace
 from celery.concurrency.base import BasePool
 from celery.five import items

+ 2 - 0
celery/concurrency/solo.py

@@ -1,7 +1,9 @@
 # -*- coding: utf-8 -*-
 """Single-threaded execution pool."""
 from __future__ import absolute_import, unicode_literals
+
 import os
+
 from .base import BasePool, apply_target
 
 __all__ = ('TaskPool',)

+ 1 - 0
celery/contrib/abortable.py

@@ -84,6 +84,7 @@ have it block until the task is finished.
    database backends.
 """
 from __future__ import absolute_import, unicode_literals
+
 from celery import Task
 from celery.result import AsyncResult
 

+ 1 - 2
celery/contrib/migrate.py

@@ -3,11 +3,10 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import socket
-
 from functools import partial
 from itertools import cycle, islice
 
-from kombu import eventloop, Queue
+from kombu import Queue, eventloop
 from kombu.common import maybe_declare
 from kombu.utils.encoding import ensure_bytes
 

+ 4 - 1
celery/contrib/pytest.py

@@ -1,8 +1,11 @@
 """Fixtures and testing utilities for :pypi:`py.test <pytest>`."""
 from __future__ import absolute_import, unicode_literals
+
 import os
-import pytest
 from contextlib import contextmanager
+
+import pytest
+
 from .testing import worker
 from .testing.app import TestApp, setup_default_app
 

+ 3 - 0
celery/contrib/rdb.py

@@ -42,12 +42,15 @@ Environment Variables
     base port.  The selected port will be logged by the worker.
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 import errno
 import os
 import socket
 import sys
 from pdb import Pdb
+
 from billiard.process import current_process
+
 from celery.five import range
 
 __all__ = (

+ 3 - 1
celery/contrib/sphinx.py

@@ -29,9 +29,11 @@ using `:task:proj.tasks.add` syntax.
 Use ``.. autotask::`` to manually document a task.
 """
 from __future__ import absolute_import, unicode_literals
+
+from celery.app.task import BaseTask
 from sphinx.domains.python import PyModulelevel
 from sphinx.ext.autodoc import FunctionDocumenter
-from celery.app.task import BaseTask
+
 try:  # pragma: no cover
     from inspect import formatargspec, getfullargspec
 except ImportError:  # Py2

+ 4 - 2
celery/contrib/testing/app.py

@@ -1,11 +1,13 @@
 """Create Celery app instances used for testing."""
 from __future__ import absolute_import, unicode_literals
+
 import weakref
 from contextlib import contextmanager
 from copy import deepcopy
+
 from kombu.utils.imports import symbol_by_name
-from celery import Celery
-from celery import _state
+
+from celery import Celery, _state
 
 #: Contains the default configuration values for the test app.
 DEFAULT_TEST_CONFIG = {

+ 0 - 1
celery/contrib/testing/manager.py

@@ -3,7 +3,6 @@ from __future__ import absolute_import, print_function, unicode_literals
 
 import socket
 import sys
-
 from collections import defaultdict
 from functools import partial
 from itertools import count

+ 2 - 0
celery/contrib/testing/mocks.py

@@ -1,7 +1,9 @@
 """Useful mocks for unit testing."""
 from __future__ import absolute_import, unicode_literals
+
 import numbers
 from datetime import datetime, timedelta
+
 try:
     from case import Mock
 except ImportError:

+ 1 - 0
celery/contrib/testing/tasks.py

@@ -1,5 +1,6 @@
 """Helper tasks for integration tests."""
 from __future__ import absolute_import, unicode_literals
+
 from celery import shared_task
 
 

+ 3 - 1
celery/contrib/testing/worker.py

@@ -1,10 +1,12 @@
 """Embedded workers for integration tests."""
 from __future__ import absolute_import, unicode_literals
+
 import os
 import threading
 from contextlib import contextmanager
+
 from celery import worker
-from celery.result import allow_join_result, _set_task_join_will_block
+from celery.result import _set_task_join_will_block, allow_join_result
 from celery.utils.dispatch import Signal
 from celery.utils.nodenames import anon_nodename
 

+ 2 - 4
celery/events/cursesmon.py

@@ -5,15 +5,13 @@ from __future__ import absolute_import, print_function, unicode_literals
 import curses
 import sys
 import threading
-
 from datetime import datetime
 from itertools import count
+from math import ceil
 from textwrap import wrap
 from time import time
-from math import ceil
 
-from celery import VERSION_BANNER
-from celery import states
+from celery import VERSION_BANNER, states
 from celery.app import app_or_default
 from celery.five import items, values
 from celery.utils.text import abbr, abbrtask

+ 0 - 1
celery/events/dispatcher.py

@@ -4,7 +4,6 @@ from __future__ import absolute_import, unicode_literals
 import os
 import threading
 import time
-
 from collections import defaultdict, deque
 
 from kombu import Producer

+ 2 - 0
celery/events/dumper.py

@@ -5,8 +5,10 @@ This is a simple program that dumps events to the console
 as they happen.  Think of it like a `tcpdump` for Celery events.
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 import sys
 from datetime import datetime
+
 from celery.app import app_or_default
 from celery.utils.functional import LRUCache
 from celery.utils.time import humanize_seconds

+ 2 - 0
celery/events/event.py

@@ -1,7 +1,9 @@
 """Creating events, and event exchange definition."""
 from __future__ import absolute_import, unicode_literals
+
 import time
 from copy import copy
+
 from kombu import Exchange
 
 __all__ = (

+ 0 - 1
celery/events/receiver.py

@@ -2,7 +2,6 @@
 from __future__ import absolute_import, unicode_literals
 
 import time
-
 from operator import itemgetter
 
 from kombu import Queue

+ 3 - 1
celery/events/snapshot.py

@@ -8,14 +8,16 @@ implementation of this writing the snapshots to a database
 in :mod:`djcelery.snapshots` in the `django-celery` distribution.
 """
 from __future__ import absolute_import, print_function, unicode_literals
+
 from kombu.utils.limits import TokenBucket
+
 from celery import platforms
 from celery.app import app_or_default
-from celery.utils.timer2 import Timer
 from celery.utils.dispatch import Signal
 from celery.utils.imports import instantiate
 from celery.utils.log import get_logger
 from celery.utils.time import rate
+from celery.utils.timer2 import Timer
 
 __all__ = ('Polaroid', 'evcam')
 

+ 0 - 1
celery/events/state.py

@@ -18,7 +18,6 @@ from __future__ import absolute_import, unicode_literals
 import bisect
 import sys
 import threading
-
 from collections import Callable, defaultdict
 from datetime import datetime
 from decimal import Decimal

+ 6 - 4
celery/exceptions.py

@@ -48,13 +48,15 @@ Error Hierarchy
         - :exc:`~celery.exceptions.WorkerShutdown`
 """
 from __future__ import absolute_import, unicode_literals
+
 import numbers
-from .five import python_2_unicode_compatible, string_t
-from billiard.exceptions import (
-    SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError, Terminated,
-)
+
+from billiard.exceptions import (SoftTimeLimitExceeded, Terminated,
+                                 TimeLimitExceeded, WorkerLostError)
 from kombu.exceptions import OperationalError
 
+from .five import python_2_unicode_compatible, string_t
+
 __all__ = (
     # Warnings
     'CeleryWarning',

+ 3 - 0
celery/five.py

@@ -1,6 +1,9 @@
 # -*- coding: utf-8 -*-
 """Python 2/3 compatibility utilities."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
+
 import vine.five
+
 sys.modules[__name__] = vine.five

+ 3 - 5
celery/fixups/django.py

@@ -4,15 +4,13 @@ from __future__ import absolute_import, unicode_literals
 import os
 import sys
 import warnings
+from datetime import datetime
+from importlib import import_module
 
 from kombu.utils.imports import symbol_by_name
 from kombu.utils.objects import cached_property
 
-from datetime import datetime
-from importlib import import_module
-
-from celery import _state
-from celery import signals
+from celery import _state, signals
 from celery.exceptions import FixupWarning, ImproperlyConfigured
 
 __all__ = ('DjangoFixup', 'fixup')

+ 1 - 0
celery/loaders/app.py

@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 """The default loader used with custom app instances."""
 from __future__ import absolute_import, unicode_literals
+
 from .base import BaseLoader
 
 __all__ = ('AppLoader',)

+ 2 - 4
celery/loaders/base.py

@@ -6,7 +6,6 @@ import importlib
 import os
 import re
 import sys
-
 from datetime import datetime
 
 from kombu.utils import json
@@ -16,9 +15,8 @@ from celery import signals
 from celery.five import reraise, string_t
 from celery.utils.collections import DictAttribute, force_mapping
 from celery.utils.functional import maybe_list
-from celery.utils.imports import (
-    import_from_cwd, symbol_by_name, NotAPackage, find_module,
-)
+from celery.utils.imports import (NotAPackage, find_module, import_from_cwd,
+                                  symbol_by_name)
 
 __all__ = ('BaseLoader',)
 

+ 3 - 0
celery/loaders/default.py

@@ -1,11 +1,14 @@
 # -*- coding: utf-8 -*-
 """The default loader used when no custom app has been initialized."""
 from __future__ import absolute_import, unicode_literals
+
 import os
 import warnings
+
 from celery.exceptions import NotConfigured
 from celery.utils.collections import DictAttribute
 from celery.utils.serialization import strtobool
+
 from .base import BaseLoader
 
 __all__ = ('Loader', 'DEFAULT_CONFIG_MODULE')

+ 2 - 0
celery/local.py

@@ -7,11 +7,13 @@ soon as possible, and that shall not load any third party modules.
 Parts of this module is Copyright by Werkzeug Team.
 """
 from __future__ import absolute_import, unicode_literals
+
 import operator
 import sys
 from functools import reduce
 from importlib import import_module
 from types import ModuleType
+
 from .five import bytes_if_py2, items, string, string_t
 
 __all__ = ('Proxy', 'PromiseProxy', 'try_import', 'maybe_evaluate')

+ 3 - 4
celery/platforms.py

@@ -15,18 +15,17 @@ import platform as _platform
 import signal as _signal
 import sys
 import warnings
-
 from collections import namedtuple
+from contextlib import contextmanager
 
-from billiard.compat import get_fdmax, close_open_fds
+from billiard.compat import close_open_fds, get_fdmax
 # fileno used to be in this module
 from kombu.utils.compat import maybe_fileno
 from kombu.utils.encoding import safe_str
-from contextlib import contextmanager
 
 from .exceptions import SecurityError
-from .local import try_import
 from .five import items, reraise, string_t
+from .local import try_import
 
 try:
     from billiard.process import current_process

+ 3 - 6
celery/result.py

@@ -3,7 +3,6 @@
 from __future__ import absolute_import, unicode_literals
 
 import time
-
 from collections import OrderedDict, deque
 from contextlib import contextmanager
 from copy import copy
@@ -11,14 +10,12 @@ from copy import copy
 from kombu.utils.objects import cached_property
 from vine import Thenable, barrier, promise
 
-from . import current_app
-from . import states
+from . import current_app, states
 from ._state import _set_task_join_will_block, task_join_will_block
 from .app import app_or_default
 from .exceptions import ImproperlyConfigured, IncompleteStream, TimeoutError
-from .five import (
-    items, python_2_unicode_compatible, range, string_t, monotonic,
-)
+from .five import (items, monotonic, python_2_unicode_compatible, range,
+                   string_t)
 from .utils import deprecated
 from .utils.graph import DependencyGraph, GraphFormatter
 

+ 2 - 5
celery/schedules.py

@@ -4,7 +4,6 @@ from __future__ import absolute_import, unicode_literals
 
 import numbers
 import re
-
 from bisect import bisect, bisect_left
 from collections import Iterable, namedtuple
 from datetime import datetime, timedelta
@@ -14,10 +13,8 @@ from kombu.utils.objects import cached_property
 from . import current_app
 from .five import python_2_unicode_compatible, range, string_t
 from .utils.collections import AttributeDict
-from .utils.time import (
-    weekday, maybe_timedelta, remaining, humanize_seconds,
-    timezone, maybe_make_aware, ffwd, localize
-)
+from .utils.time import (ffwd, humanize_seconds, localize, maybe_make_aware,
+                         maybe_timedelta, remaining, timezone, weekday)
 
 __all__ = (
     'ParseException', 'schedule', 'crontab', 'crontab_parser',

+ 4 - 0
celery/security/certificate.py

@@ -1,11 +1,15 @@
 # -*- coding: utf-8 -*-
 """X.509 certificates."""
 from __future__ import absolute_import, unicode_literals
+
 import glob
 import os
+
 from kombu.utils.encoding import bytes_to_str
+
 from celery.exceptions import SecurityError
 from celery.five import values
+
 from .utils import crypto, reraise_errors
 
 __all__ = ('Certificate', 'CertStore', 'FSCertStore')

+ 2 - 0
celery/security/key.py

@@ -1,7 +1,9 @@
 # -*- coding: utf-8 -*-
 """Private keys for the security serializer."""
 from __future__ import absolute_import, unicode_literals
+
 from kombu.utils.encoding import ensure_bytes
+
 from .utils import crypto, reraise_errors
 
 __all__ = ('PrivateKey',)

+ 3 - 3
celery/security/serialization.py

@@ -2,11 +2,11 @@
 """Secure serializer."""
 from __future__ import absolute_import, unicode_literals
 
-from kombu.serialization import registry, dumps, loads
-from kombu.utils.encoding import bytes_to_str, str_to_bytes, ensure_bytes
+from kombu.serialization import dumps, loads, registry
+from kombu.utils.encoding import bytes_to_str, ensure_bytes, str_to_bytes
 
 from celery.five import bytes_if_py2
-from celery.utils.serialization import b64encode, b64decode
+from celery.utils.serialization import b64decode, b64encode
 
 from .certificate import Certificate, FSCertStore
 from .key import PrivateKey

+ 3 - 0
celery/security/utils.py

@@ -1,10 +1,13 @@
 # -*- coding: utf-8 -*-
 """Utilities used by the message signing serializer."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
 from contextlib import contextmanager
+
 from celery.exceptions import SecurityError
 from celery.five import reraise
+
 try:
     from OpenSSL import crypto
 except ImportError:  # pragma: no cover

+ 1 - 0
celery/signals.py

@@ -12,6 +12,7 @@ functions are called whenever a signal is called.
     :ref:`signals` for more information.
 """
 from __future__ import absolute_import, unicode_literals
+
 from .utils.dispatch import Signal
 
 __all__ = (

+ 4 - 1
celery/task/base.py

@@ -7,9 +7,12 @@ This contains the backward compatible Task class used in the old API,
 and shouldn't be used in new applications.
 """
 from __future__ import absolute_import, unicode_literals
+
 from kombu import Exchange
+
 from celery import current_app
-from celery.app.task import Context, Task as BaseTask, _reprtask
+from celery.app.task import Task as BaseTask
+from celery.app.task import Context, _reprtask
 from celery.five import python_2_unicode_compatible, with_metaclass
 from celery.local import Proxy, class_property, reclassmethod
 from celery.schedules import maybe_schedule

+ 2 - 0
celery/utils/abstract.py

@@ -1,8 +1,10 @@
 # -*- coding: utf-8 -*-
 """Abstract classes."""
 from __future__ import absolute_import, unicode_literals
+
 from abc import ABCMeta, abstractmethod, abstractproperty
 from collections import Callable
+
 from celery.five import with_metaclass
 
 __all__ = ('CallableTask', 'CallableSignature')

+ 6 - 8
celery/utils/collections.py

@@ -3,16 +3,14 @@
 from __future__ import absolute_import, unicode_literals
 
 import sys
-from celery.five import monotonic
-
-from collections import (
-    Callable, Mapping, MutableMapping, MutableSet, Sequence,
-    OrderedDict as _OrderedDict, deque,
-)
-from heapq import heapify, heappush, heappop
+from collections import OrderedDict as _OrderedDict
+from collections import (Callable, Mapping, MutableMapping, MutableSet,
+                         Sequence, deque)
+from heapq import heapify, heappop, heappush
 from itertools import chain, count
 
-from celery.five import Empty, items, keys, python_2_unicode_compatible, values
+from celery.five import (Empty, items, keys, monotonic,
+                         python_2_unicode_compatible, values)
 
 from .functional import first, uniq
 from .text import match_case

+ 0 - 1
celery/utils/debug.py

@@ -5,7 +5,6 @@ from __future__ import absolute_import, print_function, unicode_literals
 import os
 import sys
 import traceback
-
 from contextlib import contextmanager
 from functools import partial
 from pprint import pprint

+ 4 - 1
celery/utils/deprecated.py

@@ -1,9 +1,12 @@
 # -*- coding: utf-8 -*-
 """Deprecation utilities."""
 from __future__ import absolute_import, print_function, unicode_literals
+
 import warnings
+
 from vine.utils import wraps
-from celery.exceptions import CPendingDeprecationWarning, CDeprecationWarning
+
+from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning
 
 __all__ = ('Callable', 'Property', 'warn')
 

+ 6 - 2
celery/utils/dispatch/signal.py

@@ -1,17 +1,21 @@
 # -*- coding: utf-8 -*-
 """Implementation of the Observer pattern."""
 from __future__ import absolute_import, unicode_literals
+
 import sys
 import threading
-import weakref
 import warnings
+import weakref
+
 from kombu.utils.functional import retry_over_time
+
 from celery.exceptions import CDeprecationWarning
 from celery.five import python_2_unicode_compatible, range, text_t
 from celery.local import PromiseProxy, Proxy
 from celery.utils.functional import fun_accepts_kwargs
-from celery.utils.time import humanize_seconds
 from celery.utils.log import get_logger
+from celery.utils.time import humanize_seconds
+
 try:
     from weakref import WeakMethod
 except ImportError:

Some files were not shown because too many files changed in this diff