Skip to content

Commit

Permalink
Remove celery.five and bump vine dep (celery#6338)
Browse files Browse the repository at this point in the history
* 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+
  • Loading branch information
maybe-sybr authored Sep 7, 2020
1 parent f0dca0d commit 8d6f7a8
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 24 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 *`).
Expand Down
7 changes: 0 additions & 7 deletions celery/five.py

This file was deleted.

4 changes: 1 addition & 3 deletions celery/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
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__ = (
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'cyanide': ('https://cyanide.readthedocs.io/en/latest', None),
},
apicheck_ignore_modules=[
'celery.five',
'celery.__main__',
'celery.task',
'celery.contrib.testing',
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/task-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,15 +51,15 @@ 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:
yield status
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
Expand Down
2 changes: 1 addition & 1 deletion requirements/default.txt
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 7 deletions t/benchmarks/bench_worker.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
import sys

from kombu.five import monotonic # noqa

from celery import Celery # noqa

os.environ.update(
Expand Down Expand Up @@ -41,7 +39,7 @@


def tdiff(then):
return monotonic() - then
return time.monotonic() - then


@app.task(cur=0, time_start=None, queue='bench.worker', bare=True)
Expand All @@ -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)
Expand All @@ -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'):
Expand Down

0 comments on commit 8d6f7a8

Please sign in to comment.