repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
celery
examples/resultgraph/tasks.py
.py
# Example:: # >>> R = A.apply_async() # >>> list(joinall(R)) # [['A 0', 'A 1', 'A 2', 'A 3', 'A 4', 'A 5', 'A 6', 'A 7', 'A 8', 'A 9'], # ['B 0', 'B 1', 'B 2', 'B 3', 'B 4', 'B 5', 'B 6', 'B 7', 'B 8', 'B 9'], # ['C 0', 'C 1', 'C 2', 'C 3', 'C 4', 'C 5', 'C 6', 'C 7', 'C 8', 'C 9'], # ['D 0', 'D 1', '...
104
2,860
celery
examples/gevent/celeryconfig.py
.py
import os import sys sys.path.insert(0, os.getcwd()) # ## Note: Start worker with -P gevent, # do not use the worker_pool option. broker_url = 'amqp://guest:guest@localhost:5672//' result_backend = 'amqp' result_expires = 30 * 60 imports = ('tasks',)
14
255
celery
examples/gevent/tasks.py
.py
import requests from celery import task @task(ignore_result=True) def urlopen(url): print(f'Opening: {url}') try: requests.get(url) except requests.exceptions.RequestException as exc: print(f'Exception for {url}: {exc!r}') return url, 0 print(f'Done with: {url}') return ur...
16
325
celery
examples/periodic-tasks/myapp.py
.py
"""myapp.py Usage:: # The worker service reacts to messages by executing tasks. (window1)$ python myapp.py worker -l INFO # The beat service sends messages at scheduled intervals. (window2)$ python myapp.py beat -l INFO # XXX To diagnose problems use -l debug: (window2)$ python myapp.py beat -l de...
61
1,518
celery
examples/pydantic/tasks.py
.py
from pydantic import BaseModel from celery import Celery app = Celery('tasks', broker='amqp://') class ArgModel(BaseModel): value: int class ReturnModel(BaseModel): value: str @app.task(pydantic=True) def x(arg: ArgModel) -> ReturnModel: # args/kwargs type hinted as Pydantic model will be converted ...
22
478
celery
examples/app/myapp.py
.py
"""myapp.py Usage:: (window1)$ python myapp.py worker -l INFO (window2)$ python >>> from myapp import add >>> add.delay(16, 16).get() 32 You can also specify the app to use with the `celery` command, using the `-A` / `--app` option:: $ celery -A myapp worker -l INFO With the `-A myproj` argume...
46
822
celery
examples/stamping/visitors.py
.py
from uuid import uuid4 from celery.canvas import Signature, StampingVisitor from celery.utils.log import get_task_logger logger = get_task_logger(__name__) class MyStampingVisitor(StampingVisitor): def on_signature(self, sig: Signature, **headers) -> dict: logger.critical(f"Visitor: Sig '{sig}' is stamp...
68
2,410
celery
examples/stamping/examples.py
.py
from tasks import identity, identity_task from visitors import FullVisitor, MonitoringIdStampingVisitor from celery import chain, group def run_example1(): s1 = chain(identity_task.si("foo11"), identity_task.si("foo12")) s1.link(identity_task.si("link_foo1")) s1.link_error(identity_task.si("link_error_fo...
47
1,358
celery
examples/stamping/config.py
.py
from celery import Celery app = Celery( 'myapp', broker='redis://', backend='redis://', )
8
103
celery
examples/stamping/revoke_example.py
.py
from time import sleep from tasks import identity_task, mul, wait_for_revoke, xsum from visitors import MonitoringIdStampingVisitor from celery.canvas import Signature, chain, chord, group from celery.result import AsyncResult def create_canvas(n: int) -> Signature: """Creates a canvas to calculate: n * sum(1.....
76
2,548
celery
examples/stamping/myapp.py
.py
"""myapp.py This is a simple example of how to use the stamping feature. It uses a custom stamping visitor to stamp a workflow with a unique monitoring id stamp (per task), and a different visitor to stamp the last task in the workflow. The last task is stamped with a consistent stamp, which is used to revoke the task...
52
1,806
celery
examples/stamping/tasks.py
.py
from time import sleep from config import app from visitors import FullVisitor, MonitoringIdStampingVisitor, MyStampingVisitor from celery import Task from celery.canvas import Signature, maybe_signature from celery.utils.log import get_task_logger logger = get_task_logger(__name__) def log_demo(running_task): ...
105
3,311
celery
celery/canvas.py
.py
"""Composing task work-flows. .. seealso: You should import these from :mod:`celery` and not this module. """ import itertools import operator import types import warnings from abc import ABCMeta, abstractmethod from collections import deque from collections.abc import MutableSequence from copy import deepcopy f...
2,444
98,253
celery
celery/_state.py
.py
"""Internal state. This is an internal module containing thread state like the ``current_app``, and ``current_task``. This module shouldn't be used directly. """ import os import sys import threading import weakref from celery.local import Proxy from celery.utils.threads import LocalStack __all__ = ( 'set_defa...
198
5,029
celery
celery/exceptions.py
.py
"""Celery error types. Error Hierarchy =============== - :exc:`Exception` - :exc:`celery.exceptions.CeleryError` - :exc:`~celery.exceptions.ImproperlyConfigured` - :exc:`~celery.exceptions.SecurityError` - :exc:`~celery.exceptions.TaskPredicate` - :exc:`~celery.exceptions.Ignor...
313
9,086
celery
celery/bootsteps.py
.py
"""A directed acyclic graph of reusable components.""" from collections import deque from threading import Event from kombu.common import ignore_errors from kombu.utils.encoding import bytes_to_str from kombu.utils.imports import symbol_by_name from .utils.graph import DependencyGraph, GraphFormatter from .utils.imp...
416
12,281
celery
celery/__main__.py
.py
"""Entry-point for the :program:`celery` umbrella command.""" import sys from . import maybe_patch_concurrency __all__ = ('main',) def main() -> None: """Entrypoint to the ``celery`` umbrella command.""" if 'multi' not in sys.argv: maybe_patch_concurrency() from celery.bin.celery import main as...
20
409
celery
celery/__init__.py
.py
"""Distributed Task Queue.""" # :copyright: (c) 2017-2026 Asif Saif Uddin, celery core and individual # contributors, All rights reserved. # :copyright: (c) 2015-2016 Ask Solem. All rights reserved. # :copyright: (c) 2012-2014 GoPivotal, Inc., All rights reserved. # :copyright: (c) 2009 - 2012 Ask Sole...
181
6,370
celery
celery/platforms.py
.py
"""Platforms. Utilities dealing with platform specifics: signals, daemonization, users, groups, and so on. """ import atexit import errno import math import numbers import os import platform as _platform import signal as _signal import sys import warnings from contextlib import contextmanager from billiard.compat im...
846
25,652
celery
celery/signals.py
.py
"""Celery Signals. This module defines the signals (Observer pattern) sent by both workers and clients. Functions can be connected to these signals, and connected functions are called whenever a signal is called. .. seealso:: :ref:`signals` for more information. """ from .utils.dispatch import Signal __all__ ...
155
4,384
celery
celery/result.py
.py
"""Task results/state and results for groups of tasks.""" import datetime import time import types from collections import deque from contextlib import contextmanager from weakref import proxy from dateutil.parser import isoparse from kombu.utils.objects import cached_property from vine import Thenable, barrier, prom...
1,133
37,396
celery
celery/beat.py
.py
"""The periodic task scheduler.""" import copy import dbm import errno import heapq import os import shelve import sys import time import traceback from calendar import timegm from collections import namedtuple from functools import total_ordering from pickle import UnpicklingError from threading import Event, Thread ...
739
24,613
celery
celery/local.py
.py
"""Proxy/PromiseProxy implementation. This module contains critical utilities that needs to be loaded as soon as possible, and that shall not load any third party modules. Parts of this module is Copyright by Werkzeug Team. """ import operator import sys import types from functools import reduce from importlib impor...
546
16,109
celery
celery/states.py
.py
"""Built-in task states. .. _states: States ------ See :ref:`task-states`. .. _statesets: Sets ---- .. state:: READY_STATES READY_STATES ~~~~~~~~~~~~ Set of states meaning the task result is ready (has been executed). .. state:: UNREADY_STATES UNREADY_STATES ~~~~~~~~~~~~~~ Set of states meaning the task resu...
152
3,324
celery
celery/schedules.py
.py
"""Schedules define the intervals at which periodic tasks run.""" from __future__ import annotations import re from bisect import bisect, bisect_left from collections import namedtuple from datetime import datetime, timedelta, tzinfo from typing import Any, Callable, Iterable, Mapping, Sequence, Union from kombu.util...
905
33,770
celery
celery/bin/purge.py
.py
"""The ``celery purge`` program, used to delete messages from queues.""" import click from celery.bin.base import COMMA_SEPARATED_LIST, CeleryCommand, CeleryOption, handle_preload_options from celery.utils import text @click.command(cls=CeleryCommand, context_settings={ 'allow_extra_args': True }) @click.option(...
71
2,608
celery
celery/bin/list.py
.py
"""The ``celery list bindings`` command, used to inspect queue bindings.""" import click from celery.bin.base import CeleryCommand, handle_preload_options @click.group(name="list") @click.pass_context @handle_preload_options def list_(ctx): """Get info from broker. Note: For RabbitMQ the management...
39
1,058
celery
celery/bin/logtool.py
.py
"""The ``celery logtool`` command.""" import re from collections import Counter from fileinput import FileInput import click from celery.bin.base import CeleryCommand, handle_preload_options __all__ = ('logtool',) RE_LOG_START = re.compile(r'^\[\d\d\d\d\-\d\d-\d\d ') RE_TASK_RECEIVED = re.compile(r'.+?\] Received')...
158
4,267
celery
celery/bin/upgrade.py
.py
"""The ``celery upgrade`` command, used to upgrade from previous versions.""" import codecs import sys import click from celery.app import defaults from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options from celery.utils.functional import pass1 @click.group() @click.pass_context @handle_pre...
92
3,064
celery
celery/bin/amqp.py
.py
"""AMQP 0.9.1 REPL.""" import pprint import click from amqp import Connection, Message from click_repl import register_repl __all__ = ('amqp',) from celery.bin.base import handle_preload_options def dump_message(message): if message is None: return 'No messages in queue. basic.publish something.' ...
313
10,023
celery
celery/bin/worker.py
.py
"""Program used to start a Celery worker instance.""" import os import sys import click from click import ParamType from click.types import StringParamType from celery import concurrency from celery.bin.base import (COMMA_SEPARATED_LIST, LOG_LEVEL, CeleryDaemonCommand, CeleryOption, hand...
372
13,519
celery
celery/bin/result.py
.py
"""The ``celery result`` program, used to inspect task results.""" import click from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options @click.command(cls=CeleryCommand) @click.argument('task_id') @click.option('-t', '--task', cls=CeleryOption, help_g...
31
976
celery
celery/bin/celery.py
.py
"""Celery Command Line Interface.""" import os import pathlib import sys import traceback from importlib.metadata import entry_points import click import click.exceptions from click_didyoumean import DYMGroup from click_plugins import with_plugins from celery import VERSION_BANNER from celery.app.utils import find_ap...
228
7,517
celery
celery/bin/multi.py
.py
"""Start multiple worker instances from the command-line. .. program:: celery multi Examples ======== .. code-block:: console $ # Single worker with explicit name and events enabled. $ celery multi start Leslie -E $ # Pidfiles and logfiles are stored in the current directory $ # by default. Use --...
481
15,374
celery
celery/bin/control.py
.py
"""The ``celery control``, ``. inspect`` and ``. status`` programs.""" from functools import partial from typing import Literal import click from kombu.utils.json import dumps from celery.bin.base import (COMMA_SEPARATED_LIST, CeleryCommand, CeleryOption, handle_preload_options, handle_re...
263
9,042
celery
celery/bin/call.py
.py
"""The ``celery call`` program used to send tasks from the command-line.""" import click from celery.bin.base import (ISO8601, ISO8601_OR_FLOAT, JSON_ARRAY, JSON_OBJECT, CeleryCommand, CeleryOption, handle_preload_options) @click.command(cls=CeleryCommand) @click.argument('name') @click....
72
2,370
celery
celery/bin/beat.py
.py
"""The :program:`celery beat` command.""" from functools import partial import click from celery.bin.base import LOG_LEVEL, CeleryDaemonCommand, CeleryOption, handle_preload_options from celery.platforms import detached, maybe_drop_privileges @click.command(cls=CeleryDaemonCommand, context_settings={ 'allow_ext...
73
2,592
celery
celery/bin/migrate.py
.py
"""The ``celery migrate`` command, used to filter and move messages.""" import click from kombu import Connection from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options from celery.contrib.migrate import migrate_tasks @click.command(cls=CeleryCommand) @click.argument('source') @click.argumen...
64
2,108
celery
celery/bin/base.py
.py
"""Click customizations for Celery.""" import json import numbers from collections import OrderedDict from functools import update_wrapper from pprint import pformat from typing import Any import click from click import Context, ParamType from kombu.exceptions import OperationalError from kombu.utils.objects import ca...
330
10,001
celery
celery/bin/graph.py
.py
"""The ``celery graph`` command.""" import sys from operator import itemgetter import click from celery.bin.base import CeleryCommand, handle_preload_options, handle_remote_command_error from celery.utils.graph import DependencyGraph, GraphFormatter @click.group() @click.pass_context @handle_preload_options def gra...
204
6,056
celery
celery/bin/shell.py
.py
"""The ``celery shell`` program, used to start a REPL.""" import os import sys from importlib import import_module import click from celery.bin.base import CeleryCommand, CeleryOption, handle_preload_options def _invoke_fallback_shell(locals): import code try: import readline except ImportError...
174
4,839
celery
celery/bin/events.py
.py
"""The ``celery events`` program.""" import sys from functools import partial import click from celery.bin.base import (LOG_LEVEL, CeleryDaemonCommand, CeleryOption, handle_preload_options, handle_remote_command_error) from celery.platforms import detached, set_process_title, strargv de...
99
2,975
celery
celery/apps/worker.py
.py
"""Worker command-line program. This module is the 'program-version' of :mod:`celery.worker`. It does everything necessary to run that module as an actual application, like installing signal handlers, platform tweaks, and so on. """ import logging import os import platform as _platform import sys from datetime import...
524
20,903
celery
celery/apps/multi.py
.py
"""Start/stop/manage workers.""" import errno import os import shlex import signal import sys from collections import OrderedDict, UserList, defaultdict from functools import partial from subprocess import Popen from time import sleep from kombu.utils.encoding import from_utf8 from kombu.utils.objects import cached_pr...
510
16,591
celery
celery/apps/beat.py
.py
"""Beat command-line program. This module is the 'program-version' of :mod:`celery.beat`. It does everything necessary to run that module as an actual application, like installing signal handlers and so on. """ from __future__ import annotations import numbers import socket import sys from datetime import datetime f...
161
5,724
celery
celery/security/utils.py
.py
"""Utilities used by the message signing serializer.""" import sys from contextlib import contextmanager import cryptography.exceptions from cryptography.hazmat.primitives import hashes from celery.exceptions import SecurityError, reraise __all__ = ('get_digest_algorithm', 'reraise_errors',) def get_digest_algorit...
29
845
celery
celery/security/key.py
.py
"""Private keys for the security serializer.""" from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import padding, rsa from kombu.utils.encoding import ensure_bytes from .utils import reraise_errors __all__ =...
36
1,189
celery
celery/security/__init__.py
.py
"""Message Signing Serializer.""" from kombu.serialization import disable_insecure_serializers as _disable_insecure_serializers from kombu.serialization import registry from celery.exceptions import ImproperlyConfigured from .serialization import register_auth # : need cryptography first CRYPTOGRAPHY_NOT_INSTALLED ...
75
2,363
celery
celery/security/serialization.py
.py
"""Secure serializer.""" from kombu.serialization import dumps, loads, registry from kombu.utils.encoding import bytes_to_str, ensure_bytes, str_to_bytes from celery.app.defaults import DEFAULT_SECURITY_DIGEST from celery.utils.serialization import b64decode, b64encode from .certificate import Certificate, FSCertStor...
91
3,832
celery
celery/security/certificate.py
.py
"""X.509 certificates.""" from __future__ import annotations import datetime import glob import os from typing import TYPE_CHECKING, Iterator from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import padding, rsa from cryptography.x509 import load_pem_x509_certific...
114
4,030
celery
celery/events/receiver.py
.py
"""Event receiver implementation.""" import time from operator import itemgetter from kombu import Queue from kombu.connection import maybe_channel from kombu.mixins import ConsumerMixin from celery import uuid from celery.app import app_or_default from celery.exceptions import ImproperlyConfigured from celery.utils....
150
5,601
celery
celery/events/state.py
.py
"""In-memory representation of cluster state. This module implements a data-structure used to keep track of the state of a cluster of workers and the tasks it is working on (by consuming events). For every event consumed the state is updated, so the state represents the state of the cluster at the time of the last ev...
731
25,648
celery
celery/events/__init__.py
.py
"""Monitoring Event Receiver+Dispatcher. Events is a stream of messages sent for certain actions occurring in the worker (and clients if :setting:`task_send_sent_event` is enabled), used for monitoring purposes. """ from .dispatcher import EventDispatcher from .event import Event, event_exchange, get_exchange, group_...
16
477
celery
celery/events/dumper.py
.py
"""Utility to dump events to screen. This is a simple program that dumps events to the console as they happen. Think of it like a `tcpdump` for Celery events. """ import sys from datetime import datetime, timezone from celery.app import app_or_default from celery.utils.functional import LRUCache from celery.utils.ti...
104
3,137
celery
celery/events/snapshot.py
.py
"""Periodically store events in a database. Consuming the events as a stream isn't always suitable so this module implements a system to take snapshots of the state of a cluster at regular intervals. There's a full implementation of this writing the snapshots to a database in :mod:`djcelery.snapshots` in the `django-...
112
3,294
celery
celery/events/event.py
.py
"""Creating events, and event exchange definition.""" import time from copy import copy from kombu import Exchange __all__ = ( 'Event', 'event_exchange', 'get_exchange', 'group_from', ) EVENT_EXCHANGE_NAME = 'celeryev' #: Exchange used to send events on. #: Note: Use :func:`get_exchange` instead, as the type of ...
64
1,750
celery
celery/events/dispatcher.py
.py
"""Event dispatcher sends events.""" import os import threading import time from collections import defaultdict, deque from kombu import Producer from celery.app import app_or_default from celery.utils.nodenames import anon_nodename from celery.utils.time import utcoffset from .event import Event, get_exchange, gro...
236
9,270
celery
celery/events/cursesmon.py
.py
"""Graphical monitor of Celery events using curses.""" import curses import sys import threading from datetime import datetime, timezone from itertools import count from math import ceil from textwrap import wrap from time import time from celery import VERSION_BANNER, states from celery.app import app_or_default fro...
535
17,985
celery
celery/loaders/app.py
.py
"""The default loader used with custom app instances.""" from .base import BaseLoader __all__ = ('AppLoader',) class AppLoader(BaseLoader): """Default loader used when an app is specified."""
9
199
celery
celery/loaders/default.py
.py
"""The default loader used when no custom app has been initialized.""" 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') ...
45
1,572
celery
celery/loaders/__init__.py
.py
"""Get loader by name. Loaders define how configuration is read, what happens when workers start, when tasks are executed and so on. """ from celery.utils.imports import import_from_cwd, symbol_by_name __all__ = ('get_loader_cls',) LOADER_ALIASES = { 'app': 'celery.loaders.app:AppLoader', 'default': 'celery....
19
490
celery
celery/loaders/base.py
.py
"""Loader base class.""" import importlib import os import re import sys from datetime import datetime, timezone from kombu.utils import json from kombu.utils.objects import cached_property from celery import signals from celery.exceptions import reraise from celery.utils.collections import DictAttribute, force_mappi...
279
9,156
celery
celery/fixups/django.py
.py
"""Django-specific customization.""" import contextlib import os import sys import warnings from datetime import datetime, timezone from importlib import import_module from typing import IO, TYPE_CHECKING, Any, List, Optional, cast from kombu.utils.imports import symbol_by_name from kombu.utils.objects import cached_p...
247
8,627
celery
celery/backends/cosmosdbsql.py
.py
"""The CosmosDB/SQL backend for Celery (experimental).""" from kombu.utils import cached_property from kombu.utils.encoding import bytes_to_str from kombu.utils.url import _parse_url from celery.exceptions import ImproperlyConfigured from celery.utils.log import get_logger from .base import KeyValueStoreBackend try:...
219
6,777
celery
celery/backends/filesystem.py
.py
"""File-system result store backend.""" import locale import os from datetime import datetime from kombu.utils.encoding import ensure_bytes from celery import uuid from celery.backends.base import KeyValueStoreBackend from celery.exceptions import ImproperlyConfigured default_encoding = locale.getpreferredencoding(F...
113
3,777
celery
celery/backends/asynchronous.py
.py
"""Async I/O backend support utilities.""" import logging import socket import threading import time from collections import deque from contextlib import contextmanager from queue import Empty from time import sleep from weakref import WeakKeyDictionary from kombu.utils.compat import detect_environment from celery i...
450
14,378
celery
celery/backends/couchbase.py
.py
"""Couchbase result store backend.""" from kombu.utils.url import _parse_url from celery.exceptions import ImproperlyConfigured from .base import KeyValueStoreBackend try: from couchbase.auth import PasswordAuthenticator from couchbase.cluster import Cluster except ImportError: Cluster = PasswordAuthent...
115
3,393
celery
celery/backends/azureblockblob.py
.py
"""The Azure Storage Block Blob backend for Celery.""" from kombu.transport.azurestoragequeues import Transport as AzureStorageQueuesTransport from kombu.utils import cached_property from kombu.utils.encoding import bytes_to_str from celery.exceptions import ImproperlyConfigured from celery.utils.log import get_logger...
189
6,071
celery
celery/backends/dynamodb.py
.py
"""AWS DynamoDB result store backend.""" from collections import namedtuple from ipaddress import ip_address from time import sleep, time from typing import Any, Dict from kombu.utils.url import _parse_url as parse_url from celery.exceptions import ImproperlyConfigured from celery.utils.log import get_logger from .b...
557
19,580
celery
celery/backends/rpc.py
.py
"""The ``RPC`` result backend for AMQP brokers. RPC-style result backend, using reply-to and one queue per client. """ import logging 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 from celery import s...
450
16,216
celery
celery/backends/s3.py
.py
"""s3 result store backend.""" from kombu.utils.encoding import bytes_to_str from celery.exceptions import ImproperlyConfigured from .base import KeyValueStoreBackend try: import boto3 import botocore except ImportError: boto3 = None botocore = None __all__ = ('S3Backend',) class S3Backend(KeyVa...
88
2,753
celery
celery/backends/cassandra.py
.py
"""Apache Cassandra result store backend using the DataStax driver.""" import threading 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 import...
257
9,014
celery
celery/backends/consul.py
.py
"""Consul result store backend. - :class:`ConsulBackend` implements KeyValueStoreBackend to store results in the key-value store of Consul. """ from kombu.utils.encoding import bytes_to_str from kombu.utils.url import parse_url from celery.backends.base import KeyValueStoreBackend from celery.exceptions import Im...
117
3,816
celery
celery/backends/gcs.py
.py
"""Google Cloud Storage result store backend for Celery.""" from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timedelta, timezone from os import getpid from threading import RLock from kombu.utils.encoding import bytes_to_str from kombu.utils.functional import dictfilter from kombu.utils...
355
12,591
celery
celery/backends/elasticsearch.py
.py
"""Elasticsearch result store backend.""" from datetime import datetime, timezone from kombu.utils.encoding import bytes_to_str from kombu.utils.url import _parse_url from celery import states from celery.exceptions import ImproperlyConfigured from .base import KeyValueStoreBackend try: import elasticsearch exc...
284
9,582
celery
celery/backends/redis.py
.py
"""Redis result store backend.""" import time from functools import partial from ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED from urllib.parse import unquote from kombu.utils import symbol_by_name from kombu.utils.functional import retry_over_time from kombu.utils.objects import cached_property from kombu.utils...
807
32,708
celery
celery/backends/mongodb.py
.py
"""MongoDB result store backend.""" from datetime import datetime, timedelta, timezone from kombu.exceptions import EncodeError from kombu.utils.objects import cached_property from kombu.utils.url import maybe_sanitize_url, urlparse from celery import states from celery.exceptions import ImproperlyConfigured from .b...
342
11,697
celery
celery/backends/cache.py
.py
"""Memcached and in-memory cache result backend.""" 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__ = ('CacheBacke...
164
4,831
celery
celery/backends/arangodb.py
.py
"""ArangoDb result store backend.""" # pylint: disable=W1202,W0703 from datetime import timedelta from kombu.utils.objects import cached_property from kombu.utils.url import _parse_url from celery.exceptions import ImproperlyConfigured from .base import KeyValueStoreBackend try: from pyArango import connectio...
191
5,937
celery
celery/backends/base.py
.py
"""Result backend base classes. - :class:`BaseBackend` defines the interface. - :class:`KeyValueStoreBackend` is a common base class using K/V semantics like _get and _put. """ import sys import time import warnings from collections import deque, namedtuple from datetime import timedelta from functools import par...
1,285
51,386
celery
celery/backends/couchdb.py
.py
"""CouchDB result store backend.""" from kombu.utils.encoding import bytes_to_str from kombu.utils.url import _parse_url from celery.exceptions import ImproperlyConfigured from .base import KeyValueStoreBackend try: import pycouchdb except ImportError: pycouchdb = None __all__ = ('CouchBackend',) ERR_LIB_M...
101
2,967
celery
celery/backends/database/models.py
.py
"""Database models used by the SQLAlchemy result store backend.""" from datetime import datetime, timezone import sqlalchemy as sa from sqlalchemy.types import PickleType from celery import states from .session import ResultModelBase __all__ = ('Task', 'TaskExtended', 'TaskSet') DialectSpecificInteger = sa.Intege...
122
3,746
celery
celery/backends/database/__init__.py
.py
"""SQLAlchemy result store backend.""" import logging from contextlib import contextmanager from celery import states from celery.backends.base import BaseBackend from celery.exceptions import ImproperlyConfigured from celery.utils.imports import symbol_by_name from celery.utils.time import maybe_timedelta from .mode...
259
9,517
celery
celery/backends/database/session.py
.py
"""SQLAlchemy session.""" import time from kombu.utils.compat import register_after_fork from sqlalchemy import create_engine from sqlalchemy.exc import DatabaseError from sqlalchemy.orm import sessionmaker from sqlalchemy.pool import NullPool from celery.utils.time import get_exponential_backoff_interval try: f...
107
3,716
celery
celery/utils/functional.py
.py
"""Functional-style utilities.""" import inspect import sys from collections import UserList from functools import partial from itertools import islice, tee, zip_longest from typing import Any, Callable from kombu.utils.functional import LRUCache, dictfilter, is_list, lazy, maybe_evaluate, maybe_list, memoize from vin...
459
14,575
celery
celery/utils/objects.py
.py
"""Object related utilities, including introspection, etc.""" import types from functools import reduce __all__ = ('Bunch', 'FallbackContext', 'getitem_property', 'mro_lookup') class Bunch: """Object that enables you to modify attributes.""" def __init__(self, **kwargs): self.__dict__.update(kwargs)...
146
4,285
celery
celery/utils/__init__.py
.py
"""Utility functions. Don't import from here directly anymore, as these are only here for backwards compatibility. """ from kombu.utils.objects import cached_property from kombu.utils.uuid import uuid from .functional import chunks, memoize, noop from .imports import gen_task_name, import_from_cwd, instantiate from ....
37
914
celery
celery/utils/debug.py
.py
"""Utilities for debugging memory usage, blocking calls, etc.""" import os import sys import traceback from contextlib import contextmanager from functools import partial from pprint import pprint from celery.platforms import signals from celery.utils.text import WhateverIO try: from psutil import Process except ...
194
4,709
celery
celery/utils/timer2.py
.py
"""Scheduler for Python functions. .. note:: This is used for the thread-based worker only, not for amqp/redis/sqs/qpid where :mod:`kombu.asynchronous.timer` is used. """ import os import sys import threading from itertools import count from threading import TIMEOUT_MAX as THREAD_TIMEOUT_MAX from time import s...
161
5,541
celery
celery/utils/iso8601.py
.py
"""Parse ISO8601 dates. Originally taken from :pypi:`pyiso8601` (https://bitbucket.org/micktwomey/pyiso8601) Modified to match the behavior of ``dateutil.parser``: - raise :exc:`ValueError` instead of ``ParseError`` - return naive :class:`~datetime.datetime` by default This is the original License: Copyrig...
77
2,916
celery
celery/utils/term.py
.py
"""Terminals and colors.""" from __future__ import annotations import base64 import os import platform import sys from functools import reduce __all__ = ('colored',) from typing import Any BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) OP_SEQ = '\033[%dm' RESET_SEQ = '\033[0m' COLOR_SEQ = '\033[1;...
185
5,209
celery
celery/utils/abstract.py
.py
"""Abstract classes.""" from abc import ABCMeta, abstractmethod from collections.abc import Callable __all__ = ('CallableTask', 'CallableSignature') def _hasattr(C, attr): return any(attr in B.__dict__ for B in C.__mro__) class _AbstractClass(metaclass=ABCMeta): __required_attributes__ = frozenset() @...
147
2,874
celery
celery/utils/log.py
.py
"""Logging utilities.""" import logging import numbers import os import sys import threading import traceback from contextlib import contextmanager from typing import AnyStr, Sequence # noqa from kombu.log import LOG_LEVELS from kombu.log import get_logger as _get_logger from kombu.utils.encoding import safe_str fro...
296
8,756
celery
celery/utils/nodenames.py
.py
"""Worker name utilities.""" from __future__ import annotations import os import socket from functools import partial from kombu.entity import Exchange, Queue from .functional import memoize from .text import simple_format #: Exchange for worker direct queues. WORKER_DIRECT_EXCHANGE = Exchange('C.dq2') #: Format f...
115
3,163
celery
celery/utils/text.py
.py
"""Text formatting utilities.""" from __future__ import annotations import io import re from functools import partial from pprint import pformat from re import Match from textwrap import fill from typing import Any, Callable, Pattern __all__ = ( 'abbr', 'abbrtask', 'dedent', 'dedent_initial', 'ensure_newlines...
198
5,792
celery
celery/utils/time.py
.py
"""Utilities related to dates, times, intervals, and timezones.""" from __future__ import annotations import logging import numbers import os import random import sys import time as _time from calendar import monthrange from datetime import date, datetime, timedelta from datetime import timezone as datetime_timezone f...
478
16,521
celery
celery/utils/imports.py
.py
"""Utilities related to importing modules and symbols by name.""" import os import sys import warnings from contextlib import contextmanager from importlib import import_module, reload from importlib.metadata import entry_points from kombu.utils.imports import symbol_by_name #: Billiard sets this when execv is enable...
164
5,045
celery
celery/utils/annotations.py
.py
"""Code related to handling annotations.""" import sys import types import typing from inspect import isclass def is_none_type(value: typing.Any) -> bool: """Check if the given value is a NoneType.""" if sys.version_info < (3, 10): # raise Exception('below 3.10', value, type(None)) return val...
50
2,084
celery
celery/utils/sysinfo.py
.py
"""System information utilities.""" from __future__ import annotations import os from math import ceil from kombu.utils.objects import cached_property __all__ = ('load_average', 'df') if hasattr(os, 'getloadavg'): def _load_average() -> tuple[float, ...]: return tuple(ceil(l * 1e2) / 1e2 for l in os.g...
51
1,264
celery
celery/utils/threads.py
.py
"""Threading primitives and utilities.""" import os import socket import sys import threading import traceback import types from contextlib import contextmanager from threading import TIMEOUT_MAX as THREAD_TIMEOUT_MAX from celery.local import Proxy try: from greenlet import getcurrent as get_ident except ImportEr...
337
9,679