Ask Solem 9 年之前
父节点
当前提交
7a77a520e8

+ 0 - 1
celery/tests/utils/test_timer2.py

@@ -6,7 +6,6 @@ import time
 import celery.utils.timer2 as timer2
 import celery.utils.timer2 as timer2
 
 
 from celery.tests.case import Case, Mock, patch, call
 from celery.tests.case import Case, Mock, patch, call
-from kombu.tests.case import redirect_stdouts
 
 
 
 
 class test_Timer(Case):
 class test_Timer(Case):

+ 7 - 7
celery/utils/functional.py

@@ -9,10 +9,8 @@
 from __future__ import absolute_import, print_function, unicode_literals
 from __future__ import absolute_import, print_function, unicode_literals
 
 
 import sys
 import sys
-import threading
 
 
-from collections import OrderedDict
-from functools import partial, wraps
+from functools import partial
 from inspect import isfunction
 from inspect import isfunction
 from itertools import chain, islice
 from itertools import chain, islice
 
 
@@ -22,11 +20,13 @@ from kombu.utils.functional import (
 )
 )
 from vine import promise
 from vine import promise
 
 
-from celery.five import UserDict, UserList, getfullargspec, keys, range
+from celery.five import UserList, getfullargspec, range
 
 
-__all__ = ['LRUCache', 'is_list', 'maybe_list', 'memoize', 'mlazy', 'noop',
-           'first', 'firstmethod', 'chunks', 'padlist', 'mattrgetter', 'uniq',
-           'regen', 'dictfilter', 'lazy', 'maybe_evaluate', 'head_from_fun']
+__all__ = [
+    'LRUCache', 'is_list', 'maybe_list', 'memoize', 'mlazy', 'noop',
+    'first', 'firstmethod', 'chunks', 'padlist', 'mattrgetter', 'uniq',
+    'regen', 'dictfilter', 'lazy', 'maybe_evaluate', 'head_from_fun',
+]
 
 
 IS_PY3 = sys.version_info[0] == 3
 IS_PY3 = sys.version_info[0] == 3
 IS_PY2 = sys.version_info[0] == 2
 IS_PY2 = sys.version_info[0] == 2

+ 1 - 0
docs/_ext/applyxrefs.py

@@ -1,4 +1,5 @@
 """Adds xref targets to the top of files."""
 """Adds xref targets to the top of files."""
+from __future__ import absolute_import, unicode_literals
 
 
 import sys
 import sys
 import os
 import os

+ 2 - 0
docs/_ext/celerydocs.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from docutils import nodes
 from docutils import nodes
 
 
 from sphinx.environment import NoUri
 from sphinx.environment import NoUri

+ 1 - 0
docs/_ext/literals_to_xrefs.py

@@ -2,6 +2,7 @@
 Runs through a reST file looking for old-style literals, and helps replace them
 Runs through a reST file looking for old-style literals, and helps replace them
 with new-style references.
 with new-style references.
 """
 """
+from __future__ import absolute_import, unicode_literals
 
 
 import re
 import re
 import sys
 import sys

+ 1 - 0
docs/conf.py

@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
 
 
 import sys
 import sys
 import os
 import os

+ 2 - 0
examples/app/myapp.py

@@ -22,6 +22,8 @@ name using the fully qualified form::
     $ celery -A myapp:app worker -l info
     $ celery -A myapp:app worker -l info
 
 
 """
 """
+from __future__ import absolute_import, unicode_literals
+
 from celery import Celery
 from celery import Celery
 
 
 app = Celery(
 app = Celery(

+ 2 - 0
examples/celery_http_gateway/manage.py

@@ -1,4 +1,6 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+from __future__ import absolute_import, unicode_literals
+
 from django.core.management import execute_manager
 from django.core.management import execute_manager
 try:
 try:
     import settings             # Assumed to be in the same directory.
     import settings             # Assumed to be in the same directory.

+ 2 - 0
examples/celery_http_gateway/settings.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 # Django settings for celery_http_gateway project.
 # Django settings for celery_http_gateway project.
 
 
 import django
 import django

+ 2 - 0
examples/celery_http_gateway/tasks.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from celery import task
 from celery import task
 
 
 
 

+ 2 - 0
examples/celery_http_gateway/urls.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from django.conf.urls.defaults import (  # noqa
 from django.conf.urls.defaults import (  # noqa
     url, patterns, include, handler404, handler500,
     url, patterns, include, handler404, handler500,
 )
 )

+ 0 - 16
examples/django/demoapp/tests.py

@@ -1,16 +0,0 @@
-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
-
-Replace this with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-
-class SimpleTest(TestCase):
-    def test_basic_addition(self):
-        """
-        Tests that 1 + 1 always equals 2.
-        """
-        self.assertEqual(1 + 1, 2)

+ 2 - 0
examples/django/manage.py

@@ -1,4 +1,6 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+from __future__ import absolute_import, unicode_literals
+
 import os
 import os
 import sys
 import sys
 
 

+ 2 - 0
examples/django/proj/urls.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from django.conf.urls import (  # noqa
 from django.conf.urls import (  # noqa
     patterns, include, url, handler404, handler500,
     patterns, include, url, handler404, handler500,
 )
 )

+ 2 - 0
examples/django/proj/wsgi.py

@@ -13,6 +13,8 @@ middleware here, or combine a Django application with an application of another
 framework.
 framework.
 
 
 """
 """
+from __future__ import absolute_import, unicode_literals
+
 import os
 import os
 
 
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')

+ 1 - 0
examples/eventlet/bulk_task_producer.py

@@ -1,3 +1,4 @@
+from __future__ import absolute_import, unicode_literals
 
 
 from eventlet import spawn_n, monkey_patch, Timeout
 from eventlet import spawn_n, monkey_patch, Timeout
 from eventlet.queue import LightQueue
 from eventlet.queue import LightQueue

+ 2 - 0
examples/eventlet/celeryconfig.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 import os
 import os
 import sys
 import sys
 sys.path.insert(0, os.getcwd())
 sys.path.insert(0, os.getcwd())

+ 4 - 2
examples/eventlet/tasks.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals, print_function
+
 import requests
 import requests
 
 
 from celery import task
 from celery import task
@@ -5,9 +7,9 @@ from celery import task
 
 
 @task()
 @task()
 def urlopen(url):
 def urlopen(url):
-    print('Opening: {0}'.format(url))
+    print('-open: {0}'.format(url))
     try:
     try:
         response = requests.get(url)
         response = requests.get(url)
     except Exception as exc:
     except Exception as exc:
-        print('URL {0} gave error: {1!r}'.format(url, exc))
+        print('-url {0} gave error: {1!r}'.format(url, exc))
     return len(response.text)
     return len(response.text)

+ 1 - 2
examples/eventlet/webcrawler.py

@@ -18,9 +18,8 @@ up 2.9kB(!).
 We don't have to do compression manually, just set the tasks compression
 We don't have to do compression manually, just set the tasks compression
 to "zlib", and the serializer to "pickle".
 to "zlib", and the serializer to "pickle".
 
 
-
 """
 """
-
+from __future__ import absolute_import, unicode_literals
 
 
 import re
 import re
 
 

+ 2 - 0
examples/gevent/celeryconfig.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 import os
 import os
 import sys
 import sys
 sys.path.insert(0, os.getcwd())
 sys.path.insert(0, os.getcwd())

+ 2 - 0
examples/gevent/tasks.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 import requests
 import requests
 
 
 from celery import task
 from celery import task

+ 2 - 0
examples/httpexample/manage.py

@@ -1,4 +1,6 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
+from __future__ import absolute_import, unicode_literals
+
 from django.core.management import execute_manager
 from django.core.management import execute_manager
 try:
 try:
     from . import settings  # Assumed to be in the same directory.
     from . import settings  # Assumed to be in the same directory.

+ 2 - 0
examples/httpexample/settings.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 # Django settings for httpexample project.
 # Django settings for httpexample project.
 
 
 DEBUG = True
 DEBUG = True

+ 2 - 0
examples/httpexample/urls.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from django.conf.urls.defaults import (  # noqa
 from django.conf.urls.defaults import (  # noqa
     url, patterns, include, handler500, handler404,
     url, patterns, include, handler500, handler404,
 )
 )

+ 2 - 0
examples/httpexample/views.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 from django.http import HttpResponse
 from django.http import HttpResponse
 
 
 from json import dumps
 from json import dumps

+ 3 - 1
examples/next-steps/setup.py

@@ -5,6 +5,8 @@ This can be used to distribute your tasks and worker
 as a Python package, on PyPI or on your own private package index.
 as a Python package, on PyPI or on your own private package index.
 
 
 """
 """
+from __future__ import absolute_import, unicode_literals
+
 from setuptools import setup, find_packages
 from setuptools import setup, find_packages
 
 
 setup(
 setup(
@@ -14,7 +16,7 @@ setup(
     packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
     packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
     zip_safe=False,
     zip_safe=False,
     install_requires=[
     install_requires=[
-        'celery>=3.0',
+        'celery>=4.0',
         #  'requests',
         #  'requests',
     ],
     ],
 )
 )

+ 4 - 4
examples/resultgraph/tasks.py

@@ -17,7 +17,7 @@
 #
 #
 #    >>> unlock_graph.apply_async((A.apply_async(),
 #    >>> unlock_graph.apply_async((A.apply_async(),
 #    ...                           A_callback.s()), countdown=1)
 #    ...                           A_callback.s()), countdown=1)
-
+from __future__ import absolute_import, unicode_literals
 
 
 from celery import chord, group, task, signature, uuid
 from celery import chord, group, task, signature, uuid
 from celery.result import AsyncResult, ResultSet, allow_join_result
 from celery.result import AsyncResult, ResultSet, allow_join_result
@@ -31,13 +31,13 @@ def add(x, y):
 
 
 @task()
 @task()
 def make_request(id, url):
 def make_request(id, url):
-    print('GET {0!r}'.format(url))
+    print('-get: {0!r}'.format(url))
     return url
     return url
 
 
 
 
 @task()
 @task()
 def B_callback(urls, id):
 def B_callback(urls, id):
-    print('batch {0} done'.format(id))
+    print('-batch {0} done'.format(id))
     return urls
     return urls
 
 
 
 
@@ -88,7 +88,7 @@ def unlock_graph(result, callback,
 
 
 @task()
 @task()
 def A_callback(res):
 def A_callback(res):
-    print('Everything is done: {0!r}'.format(res))
+    print('-everything done: {0!r}'.format(res))
     return res
     return res
 
 
 
 

+ 1 - 1
extra/release/sphinx-to-rst.py

@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 
 import codecs
 import codecs
 import os
 import os

+ 2 - 2
extra/release/verify_config_reference.py

@@ -1,4 +1,4 @@
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 
 from fileinput import input as _input
 from fileinput import input as _input
 from sys import exit, stderr
 from sys import exit, stderr
@@ -49,5 +49,5 @@ if __name__ == '__main__':
             file=stderr,
             file=stderr,
         )
         )
         exit(1)
         exit(1)
-    print('OK: Configuration reference complete :-)')
+    print('-Ok- configuration reference complete :-)')
     exit(0)
     exit(0)

+ 2 - 2
funtests/benchmarks/bench_worker.py

@@ -1,4 +1,4 @@
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 
 import os
 import os
 import sys
 import sys
@@ -82,7 +82,7 @@ def bench_work(n=DEFAULT_ITS, loglevel='CRITICAL'):
                                 queues=['bench.worker'])
                                 queues=['bench.worker'])
 
 
     try:
     try:
-        print('STARTING WORKER')
+        print('-- starting worker')
         worker.start()
         worker.start()
     except SystemExit:
     except SystemExit:
         raise
         raise

+ 1 - 0
funtests/setup.py

@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
 
 
 try:
 try:
     from setuptools import setup
     from setuptools import setup

+ 1 - 1
funtests/stress/stress/__init__.py

@@ -11,7 +11,7 @@ if os.environ.get('C_SLEEP'):
     _orig_sleep = time.sleep
     _orig_sleep = time.sleep
 
 
     def _sleep(n):
     def _sleep(n):
-        print('WARNING: Time sleep for {0}s'.format(n))
+        print('warning: time sleep for {0}s'.format(n))
         import traceback
         import traceback
         traceback.print_stack()
         traceback.print_stack()
         _orig_sleep(n)
         _orig_sleep(n)

+ 2 - 0
funtests/suite/__init__.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 import os
 import os
 import sys
 import sys
 
 

+ 2 - 0
funtests/suite/config.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import, unicode_literals
+
 import atexit
 import atexit
 import os
 import os
 
 

+ 2 - 2
funtests/suite/test_leak.py

@@ -1,4 +1,4 @@
-from __future__ import print_function, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
 
 
 import gc
 import gc
 import os
 import os
@@ -77,7 +77,7 @@ class LeakFunCase(unittest.TestCase):
             try:
             try:
                 assert self.appx(first) >= self.appx(after)
                 assert self.appx(first) >= self.appx(after)
             except AssertionError:
             except AssertionError:
-                print('BASE: {0!r} AVG: {1!r} SIZES: {2!r}'.format(
+                print('base: {0!r} avg: {1!r} sizes: {2!r}'.format(
                     base, sizes.average(), sizes))
                     base, sizes.average(), sizes))
                 raise
                 raise
         finally:
         finally: