Browse Source

Remove celery.five and bump vine dep (#6338)

* improv: Replace `five.values` with `dict.values`

* improv: Use `time.monotonic()` in kombu tests

Also in the docs where it is used to demonstrate `memcache` timeouts.

* rm: Delete `celery.five`

`vine.five` is no longer present in `vine >= 5`.

* triv: Remove refs to `celery.five` in docs, &c

* build: Bump `vine` dependency to 5.0+
pull/6346/head
maybe-sybr 2 years ago committed by GitHub
parent
commit
8d6f7a8a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .coveragerc
  2. 1
      CONTRIBUTING.rst
  3. 7
      celery/five.py
  4. 4
      celery/utils/log.py
  5. 1
      docs/conf.py
  6. 6
      docs/tutorials/task-cookbook.rst
  7. 2
      requirements/default.txt
  8. 12
      t/benchmarks/bench_worker.py

1
.coveragerc

@ -12,7 +12,6 @@ omit =
*/celery/bin/graph.py
*celery/bin/logtool.py
*celery/task/base.py
*celery/five.py
*celery/contrib/sphinx.py
*celery/concurrency/asynpool.py
*celery/utils/debug.py

1
CONTRIBUTING.rst

@ -1067,7 +1067,6 @@ is following the conventions.
from Queue import Queue, Empty
from .platforms import Pidfile
from .five import zip_longest, items, range
from .utils.time import maybe_timedelta
* Wild-card imports must not be used (`from xxx import *`).

7
celery/five.py

@ -1,7 +0,0 @@
"""Python 2/3 compatibility utilities."""
import sys
import vine.five
sys.modules[__name__] = vine.five

4
celery/utils/log.py

@ -11,8 +11,6 @@ from kombu.log import LOG_LEVELS
from kombu.log import get_logger as _get_logger
from kombu.utils.encoding import safe_str
from celery.five import values
from .term import colored
__all__ = (
@ -45,7 +43,7 @@ def set_in_sighandler(value):
def iter_open_logger_fds():
seen = set()
loggers = (list(values(logging.Logger.manager.loggerDict)) +
loggers = (list(logging.Logger.manager.loggerDict.values()) +
[logging.getLogger(None)])
for l in loggers:
try:

1
docs/conf.py

@ -25,7 +25,6 @@ globals().update(conf.build_config(
'cyanide': ('https://cyanide.readthedocs.io/en/latest', None),
},
apicheck_ignore_modules=[
'celery.five',
'celery.__main__',
'celery.task',
'celery.contrib.testing',

6
docs/tutorials/task-cookbook.rst

@ -37,8 +37,8 @@ For this reason your tasks run-time shouldn't exceed the timeout.
.. code-block:: python
import time
from celery import task
from celery.five import monotonic
from celery.utils.log import get_task_logger
from contextlib import contextmanager
from django.core.cache import cache
@ -51,7 +51,7 @@ For this reason your tasks run-time shouldn't exceed the timeout.
@contextmanager
def memcache_lock(lock_id, oid):
timeout_at = monotonic() + LOCK_EXPIRE - 3
timeout_at = time.monotonic() + LOCK_EXPIRE - 3
# cache.add fails if the key already exists
status = cache.add(lock_id, oid, LOCK_EXPIRE)
try:
@ -59,7 +59,7 @@ For this reason your tasks run-time shouldn't exceed the timeout.
finally:
# memcache delete is very slow, but we have to use it to take
# advantage of using add() for atomic locking
if monotonic() < timeout_at and status:
if time.monotonic() < timeout_at and status:
# don't release the lock if we exceeded the timeout
# to lessen the chance of releasing an expired lock
# owned by someone else

2
requirements/default.txt

@ -1,7 +1,7 @@
pytz>dev
billiard>=3.6.3.0,<4.0
kombu>=5.0.0,<6.0
vine==1.3.0
vine>=5.0.0,<6.0
click>=7.0
click-didyoumean>=0.0.3
click-repl>=0.1.6

12
t/benchmarks/bench_worker.py

@ -1,8 +1,6 @@
import os
import sys
from kombu.five import monotonic # noqa
from celery import Celery # noqa
os.environ.update(
@ -41,7 +39,7 @@ app.conf.update(
def tdiff(then):
return monotonic() - then
return time.monotonic() - then
@app.task(cur=0, time_start=None, queue='bench.worker', bare=True)
@ -51,9 +49,9 @@ def it(_, n):
i = it.cur
if i and not i % 5000:
print('({} so far: {}s)'.format(i, tdiff(it.subt)), file=sys.stderr)
it.subt = monotonic()
it.subt = time.monotonic()
if not i:
it.subt = it.time_start = monotonic()
it.subt = it.time_start = time.monotonic()
elif i > n - 2:
total = tdiff(it.time_start)
print('({} so far: {}s)'.format(i, tdiff(it.subt)), file=sys.stderr)
@ -66,11 +64,11 @@ def it(_, n):
def bench_apply(n=DEFAULT_ITS):
time_start = monotonic()
time_start = time.monotonic()
task = it._get_current_object()
with app.producer_or_acquire() as producer:
[task.apply_async((i, n), producer=producer) for i in range(n)]
print('-- apply {} tasks: {}s'.format(n, monotonic() - time_start))
print('-- apply {} tasks: {}s'.format(n, time.monotonic() - time_start))
def bench_work(n=DEFAULT_ITS, loglevel='CRITICAL'):

Loading…
Cancel
Save