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
kombu
kombu/transport/__init__.py
.py
"""Built-in transports.""" from __future__ import annotations from kombu.utils.compat import _detect_environment from kombu.utils.imports import symbol_by_name def supports_librabbitmq() -> bool | None: """Return true if :pypi:`librabbitmq` can be used.""" if _detect_environment() == 'default': try:...
94
3,487
kombu
kombu/transport/azureservicebus.py
.py
"""Azure Service Bus Message Queue transport module for kombu. Note that the Shared Access Policy used to connect to Azure Service Bus requires Manage, Send and Listen claims since the broker will create new queues and delete old queues as required. Notes when using with Celery if you are experiencing issues with pr...
706
26,253
kombu
kombu/transport/pyro.py
.py
"""Pyro transport module for kombu. Pyro transport, and Kombu Broker daemon. Requires the :mod:`Pyro4` library to be installed. Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: No * Supports Priority: No * Supports TTL: No Connection String ================= To use ...
213
5,844
kombu
kombu/transport/native_delayed_delivery.py
.py
"""Native Delayed Delivery API. Only relevant for RabbitMQ. """ from __future__ import annotations from kombu import Connection, Exchange, Queue, binding from kombu.log import get_logger logger = get_logger(__name__) MAX_NUMBER_OF_BITS_TO_USE = 28 MAX_LEVEL = MAX_NUMBER_OF_BITS_TO_USE - 1 CELERY_DELAYED_DELIVERY_EX...
158
5,801
kombu
kombu/transport/consul.py
.py
"""Consul Transport module for Kombu. Features ======== It uses Consul.io's Key/Value store to transport messages in Queues It uses python-consul for talking to Consul's HTTP API Features ======== * Type: Native * Supports Direct: Yes * Supports Topic: *Unreviewed* * Supports Fanout: *Unreviewed* * Supports Priorit...
324
9,424
kombu
kombu/transport/confluentkafka.py
.py
"""confluent-kafka transport module for Kombu. Kafka transport using confluent-kafka library. **References** - http://docs.confluent.io/current/clients/confluent-kafka-python **Limitations** The confluent-kafka transport does not support PyPy environment. Features ======== * Type: Virtual * Supports Direct: Yes *...
381
12,141
kombu
kombu/transport/redis.py
.py
"""Redis transport module for Kombu. Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: Yes * Supports Priority: Yes * Supports Queue TTL: Yes * Supports Message TTL: No Connection String ================= Connection string has the following format: .. code-block:: ...
1,666
59,396
kombu
kombu/transport/mongodb.py
.py
# copyright: (c) 2010 - 2013 by Flavio Percoco Premoli. # license: BSD, see LICENSE for more details. """MongoDB transport module for kombu. Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: Yes * Supports Priority: Yes * Supports TTL: Yes Connection String ===========...
555
16,786
kombu
kombu/transport/librabbitmq.py
.py
"""`librabbitmq`_ transport. .. _`librabbitmq`: https://pypi.org/project/librabbitmq/ """ from __future__ import annotations import os import socket import warnings import librabbitmq as amqp from librabbitmq import ChannelError, ConnectionError from kombu.utils.amq_manager import get_manager from kombu.utils.text...
198
6,413
kombu
kombu/transport/pyamqp.py
.py
"""pyamqp transport module for Kombu. Pure-Python amqp transport using py-amqp library. Features ======== * Type: Native * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: Yes * Supports Priority: Yes * Supports TTL: Yes Connection String ================= Connection string can have the following format...
266
8,324
kombu
kombu/transport/azurestoragequeues.py
.py
"""Azure Storage Queues transport module for kombu. More information about Azure Storage Queues: https://azure.microsoft.com/en-us/services/storage/queues/ Features ======== * Type: Virtual * Supports Direct: *Unreviewed* * Supports Topic: *Unreviewed* * Supports Fanout: *Unreviewed* * Supports Priority: *Unreviewed*...
264
8,878
kombu
kombu/transport/base.py
.py
"""Base transport interface.""" # flake8: noqa from __future__ import annotations import errno import socket from typing import TYPE_CHECKING from amqp.exceptions import RecoverableConnectionError from kombu.exceptions import ChannelError, ConnectionError from kombu.message import Message from kombu.utils.function...
272
7,687
kombu
kombu/transport/zookeeper.py
.py
# copyright: (c) 2010 - 2013 by Mahendra M. # license: BSD, see LICENSE for more details. """Zookeeper transport module for kombu. Zookeeper based transport. This transport uses the built-in kazoo Zookeeper based queue implementation. **References** - https://zookeeper.apache.org/doc/current/recipes.html#sc_recipes...
224
6,339
kombu
kombu/transport/memory.py
.py
"""In-memory transport module for Kombu. Simple transport using memory for storing messages. Messages can be passed only between threads. Features ======== * Type: Virtual * Supports Direct: Yes * Supports Topic: Yes * Supports Fanout: No * Supports Priority: No * Supports TTL: Yes Connection String ================...
107
2,404
kombu
kombu/transport/qpid.py
.py
"""Qpid Transport module for kombu. `Qpid`_ transport using `qpid-python`_ as the client and `qpid-tools`_ for broker management. The use this transport you must install the necessary dependencies. These dependencies are available via PyPI and can be installed using the pip command: .. code-block:: console $ pi...
1,749
71,681
kombu
kombu/transport/SQS/SNS.py
.py
"""Amazon SNS fanout support for the AWS SQS transport module for Kombu. This module provides a `SNS` class that can be used to manage SNS topics and subscriptions. It's primarily used to provide fanout support via AWS Simple Notification Service (SNS) topics and subscriptions. The module also provides methods for han...
708
30,013
kombu
kombu/transport/SQS/exceptions.py
.py
"""AWS SQS and SNS exceptions.""" from __future__ import annotations from kombu.exceptions import KombuError class UndefinedQueueException(KombuError): """Predefined queues are being used and an undefined queue was used.""" class UndefinedExchangeException(KombuError): """Predefined exchanges are being us...
38
1,052
kombu
kombu/transport/SQS/__init__.py
.py
"""Amazon SQS transport module for Kombu. This package implements an AMQP-like interface on top of Amazons SQS service, with the goal of being optimized for high performance and reliability. The default settings for this module are focused now on high performance in task queue situations where tasks are small, idempo...
1,482
56,556
kombu
kombu/transport/sqlalchemy/models.py
.py
"""Kombu transport using SQLAlchemy as the message store.""" from __future__ import annotations import datetime from sqlalchemy import (Boolean, Column, DateTime, ForeignKey, Index, Integer, Sequence, SmallInteger, String, Text) from sqlalchemy.orm import relationship from sqlalchemy.schema i...
77
2,302
kombu
kombu/transport/sqlalchemy/__init__.py
.py
"""SQLAlchemy Transport module for kombu. Kombu transport using SQL Database as the message store. Features ======== * Type: Virtual * Supports Direct: yes * Supports Topic: yes * Supports Fanout: no * Supports Priority: no * Supports TTL: no Connection String ================= .. code-block:: sqla+SQL_ALCHEMY...
263
8,009
kombu
kombu/transport/virtual/__init__.py
.py
from __future__ import annotations from .base import (AbstractChannel, Base64, BrokerState, Channel, Empty, Management, Message, NotEquivalentError, QoS, Transport, UndeliverableWarning, binding_key_t, queue_binding_t) __all__ = ( 'Base64', 'NotEquivalentError', 'Undeliverabl...
12
476
kombu
kombu/transport/virtual/exchange.py
.py
"""Virtual AMQ Exchange. Implementations of the standard exchanges defined by the AMQ protocol (excluding the `headers` exchange). """ from __future__ import annotations import re from kombu.utils.text import escape_regex class ExchangeType: """Base class for exchanges. Implements the specifics for an e...
165
4,894
kombu
kombu/transport/virtual/base.py
.py
"""Virtual transport implementation. Emulates the AMQ API for non-AMQ transports. """ from __future__ import annotations import base64 import socket import warnings from array import array from collections import OrderedDict, defaultdict, namedtuple from itertools import count from multiprocessing.util import Finali...
1,047
34,797
kombu
kombu/asynchronous/hub.py
.py
"""Event loop implementation.""" from __future__ import annotations import errno import threading from contextlib import contextmanager from copy import copy from queue import Empty from time import sleep from types import GeneratorType as generator from vine import Thenable, promise from kombu.log import get_logge...
404
12,091
kombu
kombu/asynchronous/semaphore.py
.py
"""Semaphores and concurrency primitives.""" from __future__ import annotations import sys from collections import deque from typing import TYPE_CHECKING if TYPE_CHECKING: from types import TracebackType from typing import Callable, Deque if sys.version_info < (3, 10): from typing_extensions impor...
128
3,561
kombu
kombu/asynchronous/__init__.py
.py
"""Event loop.""" from __future__ import annotations from kombu.utils.eventio import ERR, READ, WRITE from .hub import Hub, get_event_loop, set_event_loop __all__ = ('READ', 'WRITE', 'ERR', 'Hub', 'get_event_loop', 'set_event_loop')
10
237
kombu
kombu/asynchronous/debug.py
.py
"""Event-loop debugging tools.""" from __future__ import annotations from kombu.utils.eventio import ERR, READ, WRITE from kombu.utils.functional import reprcall def repr_flag(flag): """Return description of event loop flag.""" return '{}{}{}'.format('R' if flag & READ else '', 'W...
68
1,773
kombu
kombu/asynchronous/timer.py
.py
"""Timer scheduling Python callbacks.""" from __future__ import annotations import heapq import sys from collections import namedtuple from datetime import datetime from functools import total_ordering from time import monotonic from time import time as _time from typing import TYPE_CHECKING from weakref import proxy...
242
6,922
kombu
kombu/asynchronous/aws/__init__.py
.py
from __future__ import annotations from typing import Any from kombu.asynchronous.aws.sqs.connection import AsyncSQSConnection def connect_sqs( aws_access_key_id: str | None = None, aws_secret_access_key: str | None = None, **kwargs: Any ) -> AsyncSQSConnection: """Return async connection to Amazon ...
18
475
kombu
kombu/asynchronous/aws/connection.py
.py
"""Amazon AWS Connection.""" from __future__ import annotations from email import message_from_bytes from email.mime.message import MIMEMessage from vine import promise, transform from kombu.asynchronous.aws.ext import AWSRequest, get_cert_path, get_response from kombu.asynchronous.http import Headers, Request, get...
279
8,883
kombu
kombu/asynchronous/aws/ext.py
.py
"""Amazon boto3 interface.""" from __future__ import annotations try: import boto3 from botocore import exceptions from botocore.awsrequest import AWSRequest from botocore.httpsession import get_cert_path from botocore.response import get_response except ImportError: boto3 = None class _v...
34
866
kombu
kombu/asynchronous/aws/sqs/message.py
.py
"""Amazon SQS message implementation.""" from __future__ import annotations import base64 from kombu.message import Message from kombu.utils.encoding import str_to_bytes class BaseAsyncMessage(Message): """Base class for messages received on async client.""" class AsyncRawMessage(BaseAsyncMessage): """Ra...
36
892
kombu
kombu/asynchronous/aws/sqs/connection.py
.py
"""Amazon SQS Connection.""" from __future__ import annotations import json from botocore.serialize import Serializer from vine import transform from kombu.asynchronous.aws.connection import AsyncAWSQueryConnection from kombu.asynchronous.aws.ext import AWSRequest from .ext import boto3 from .message import AsyncM...
358
12,768
kombu
kombu/asynchronous/aws/sqs/queue.py
.py
"""Amazon SQS queue implementation.""" from __future__ import annotations from vine import transform from .message import AsyncMessage _all__ = ['AsyncQueue'] def list_first(rs): """Get the first item in a list, or None if list empty.""" return rs[0] if len(rs) == 1 else None class AsyncQueue: """As...
131
4,402
kombu
kombu/asynchronous/aws/sqs/ext.py
.py
"""Amazon SQS boto3 interface.""" from __future__ import annotations try: import boto3 except ImportError: boto3 = None
10
131
kombu
kombu/asynchronous/http/curl.py
.py
"""HTTP Client using pyCurl.""" from __future__ import annotations from collections import deque from functools import partial from io import BytesIO from time import time from kombu.asynchronous.hub import READ, WRITE, Hub, get_event_loop from kombu.exceptions import HttpError from kombu.utils.encoding import bytes...
294
9,863
kombu
kombu/asynchronous/http/__init__.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from kombu.asynchronous import get_event_loop from kombu.asynchronous.http.base import Headers, Request, Response from kombu.asynchronous.hub import Hub if TYPE_CHECKING: from kombu.asynchronous.http.curl import CurlClient __all__ = ('Client', ...
29
863
kombu
kombu/asynchronous/http/base.py
.py
"""Base async HTTP client implementation.""" from __future__ import annotations import sys from http.client import responses from typing import TYPE_CHECKING from vine import Thenable, maybe_promise, promise from kombu.exceptions import HttpError from kombu.utils.compat import coro from kombu.utils.encoding import ...
275
9,592
kombu
kombu/utils/json.py
.py
"""JSON Serialization Utilities.""" from __future__ import annotations import base64 import json import uuid from datetime import date, datetime, time from decimal import Decimal from typing import Any, Callable, TypeVar textual_types = () try: from django.utils.functional import Promise textual_types += (...
147
4,088
kombu
kombu/utils/functional.py
.py
"""Functional Utilities.""" from __future__ import annotations import inspect import random import threading from collections import OrderedDict, UserDict from collections.abc import Iterable, Mapping from itertools import count, repeat from time import sleep, time from vine.utils import wraps from .encoding import...
362
10,708
kombu
kombu/utils/uuid.py
.py
"""UUID utilities.""" from __future__ import annotations from typing import Callable from uuid import UUID, uuid4 def uuid(_uuid: Callable[[], UUID] = uuid4) -> str: """Generate unique id in UUID4 format. See Also -------- For now this is provided by :func:`uuid.uuid4`. """ return str(_u...
16
327
kombu
kombu/utils/div.py
.py
"""Div. Utilities.""" from __future__ import annotations import logging import os from .encoding import default_encode logger = logging.getLogger(__name__) def emergency_dump_state(state, open_file=open, dump=None, stderr=None): """Dump message state to stdout or file.""" from pprint import pformat fr...
45
1,213
kombu
kombu/utils/objects.py
.py
"""Object Utilities.""" from __future__ import annotations from threading import RLock __all__ = ('cached_property',) try: from functools import cached_property as _cached_property except ImportError: # TODO: Remove this fallback once we drop support for Python < 3.8 from cached_property import threaded...
68
2,043
kombu
kombu/utils/__init__.py
.py
"""DEPRECATED - Import from modules below.""" from __future__ import annotations from .collections import EqualityDict from .compat import fileno, maybe_fileno, nested, register_after_fork from .div import emergency_dump_state from .functional import (fxrange, fxrangemax, maybe_list, reprcall, reprkwargs, ...
21
710
kombu
kombu/utils/eventio.py
.py
"""Selector Utilities.""" from __future__ import annotations import errno import math import select as __select__ import sys from numbers import Integral from . import fileno from .compat import detect_environment __all__ = ('poll',) _selectf = __select__.select _selecterr = __select__.error xpoll = getattr(__sele...
330
10,150
kombu
kombu/utils/debug.py
.py
"""Debugging support.""" from __future__ import annotations import logging from typing import TYPE_CHECKING from vine.utils import wraps from kombu.log import get_logger if TYPE_CHECKING: from logging import Logger from types import TracebackType from typing import Any, Callable from kombu.transpo...
89
2,355
kombu
kombu/utils/scheduling.py
.py
"""Scheduling Utilities.""" from __future__ import annotations from itertools import count from .imports import symbol_by_name __all__ = ( 'FairCycle', 'priority_cycle', 'round_robin_cycle', 'sorted_cycle', ) CYCLE_ALIASES = { 'priority': 'kombu.utils.scheduling:priority_cycle', 'round_robin': 'kombu.u...
112
2,927
kombu
kombu/utils/amq_manager.py
.py
"""AMQP Management API utilities.""" from __future__ import annotations def get_manager(client, hostname=None, port=None, userid=None, password=None): """Get pyrabbit manager.""" import pyrabbit opt = client.transport_options.get def get(name, val, default): return (val if v...
23
716
kombu
kombu/utils/encoding.py
.py
"""Text encoding utilities. Utilities to encode text, and to safely emit text from running applications without crashing from the infamous :exc:`UnicodeDecodeError` exception. """ from __future__ import annotations import sys import traceback #: safe_str takes encoding from this file by default. #: :func:`set_defau...
98
2,297
kombu
kombu/utils/limits.py
.py
"""Token bucket implementation for rate limiting.""" from __future__ import annotations from collections import deque from time import monotonic __all__ = ('TokenBucket',) class TokenBucket: """Token Bucket Algorithm. See Also -------- https://en.wikipedia.org/wiki/Token_Bucket Most o...
88
2,551
kombu
kombu/utils/text.py
.py
"""Text Utilities.""" # flake8: noqa from __future__ import annotations from difflib import SequenceMatcher from typing import Iterable, Iterator from kombu import version_info_t def escape_regex(p, white=''): # type: (str, str) -> str """Escape string for use within a regular expression.""" # what's ...
74
2,200
kombu
kombu/utils/url.py
.py
"""URL Utilities.""" # flake8: noqa from __future__ import annotations from collections.abc import Mapping from functools import partial from typing import NamedTuple from urllib.parse import parse_qsl, quote, unquote, urlparse try: import ssl ssl_available = True except ImportError: # pragma: no cover ...
133
3,909
kombu
kombu/utils/compat.py
.py
"""Python Compatibility Utilities.""" from __future__ import annotations import numbers import sys from contextlib import contextmanager from functools import wraps from importlib import metadata as importlib_metadata from io import UnsupportedOperation from kombu.exceptions import reraise FILENO_ERRORS = (Attribut...
154
3,951
kombu
kombu/utils/time.py
.py
"""Time Utilities.""" from __future__ import annotations __all__ = ('maybe_s_to_ms',) def maybe_s_to_ms(v: int | float | None) -> int | None: """Convert seconds to milliseconds, but return None for None.""" return int(float(v) * 1000.0) if v is not None else v
10
272
kombu
kombu/utils/imports.py
.py
"""Import related utilities.""" from __future__ import annotations import importlib import sys from kombu.exceptions import reraise def symbol_by_name(name, aliases=None, imp=None, package=None, sep='.', default=None, **kwargs): """Get symbol by qualified name. The name should be the fu...
69
2,089
kombu
kombu/utils/collections.py
.py
"""Custom maps, sequences, etc.""" from __future__ import annotations class HashedSeq(list): """Hashed Sequence. Type used for hash() to make sure the hash is not generated multiple times. """ __slots__ = 'hashvalue' def __init__(self, *seq): self[:] = seq self.hashvalue =...
46
942
kombu
examples/complete_send.py
.py
""" Example producer that sends a single message and exits. You can use `complete_receive.py` to receive the message sent. """ from __future__ import annotations from kombu import Connection, Exchange, Producer, Queue #: By default messages sent to exchanges are persistent (delivery_mode=2), #: and queues and exc...
37
1,174
kombu
examples/complete_receive.py
.py
""" Example of simple consumer that waits for a single message, acknowledges it and exits. """ from __future__ import annotations from pprint import pformat from kombu import Connection, Consumer, Exchange, Queue, eventloop #: By default messages sent to exchanges are persistent (delivery_mode=2), #: and queues an...
48
1,550
kombu
examples/simple_eventlet_send.py
.py
""" Example that sends a single message and exits using the simple interface. You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ from __future__ import annotations import eventlet from kombu import Connection eventlet.monkey_patch() def send_many(n): #: Create conn...
44
1,181
kombu
examples/simple_receive.py
.py
""" Example receiving a message using the SimpleQueue interface. """ from __future__ import annotations from kombu import Connection #: Create connection #: If hostname, userid, password and virtual_host is not specified #: the values below are the default, but listed here so it can #: be easily changed. with Conne...
30
939
kombu
examples/hello_publisher.py
.py
from __future__ import annotations import datetime from kombu import Connection with Connection('amqp://guest:guest@localhost:5672//') as conn: simple_queue = conn.SimpleQueue('simple_queue') message = f'helloworld, sent at {datetime.datetime.today()}' simple_queue.put(message) print(f'Sent: {message...
13
349
kombu
examples/memory_transport.py
.py
""" Example that use memory transport for message produce. """ from __future__ import annotations import time from kombu import Connection, Consumer, Exchange, Queue media_exchange = Exchange('media', 'direct') video_queue = Queue('video', exchange=media_exchange, routing_key='video') task_queues = [video_queue] d...
32
755
kombu
examples/hello_consumer.py
.py
from __future__ import annotations from kombu import Connection with Connection('amqp://guest:guest@localhost:5672//') as conn: simple_queue = conn.SimpleQueue('simple_queue') message = simple_queue.get(block=True, timeout=1) print(f'Received: {message.payload}') message.ack() simple_queue.close()...
11
321
kombu
examples/delayed_infra.py
.py
from __future__ import annotations from kombu import Connection, Exchange, Queue from kombu.transport.native_delayed_delivery import ( bind_queue_to_native_delayed_delivery_exchange, calculate_routing_key, declare_native_delayed_delivery_exchanges_and_queues, level_name) with Connection('amqp://guest:guest@lo...
24
1,060
kombu
examples/simple_eventlet_receive.py
.py
""" Example that sends a single message and exits using the simple interface. You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ from __future__ import annotations import eventlet from kombu import Connection eventlet.monkey_patch() def wait_many(timeout=1): #: Cre...
44
1,225
kombu
examples/simple_send.py
.py
""" Example that sends a single message and exits using the simple interface. You can use `simple_receive.py` (or `complete_receive.py`) to receive the message sent. """ from __future__ import annotations from kombu import Connection #: Create connection #: If hostname, userid, password and virtual_host is not sp...
33
1,001
kombu
examples/simple_task_queue/worker.py
.py
from __future__ import annotations from kombu.log import get_logger from kombu.mixins import ConsumerMixin from kombu.utils.functional import reprcall from .queues import task_queues logger = get_logger(__name__) class Worker(ConsumerMixin): def __init__(self, connection): self.connection = connection...
47
1,276
kombu
examples/simple_task_queue/client.py
.py
from __future__ import annotations from kombu.pools import producers from .queues import task_exchange priority_to_routing_key = { 'high': 'hipri', 'mid': 'midpri', 'low': 'lopri', } def send_as_task(connection, fun, args=(), kwargs={}, priority='mid'): payload = {'fun': fun, 'args': args, 'kwargs'...
35
994
kombu
examples/simple_task_queue/queues.py
.py
from __future__ import annotations from kombu import Exchange, Queue task_exchange = Exchange('tasks', type='direct') task_queues = [Queue('hipri', task_exchange, routing_key='hipri'), Queue('midpri', task_exchange, routing_key='midpri'), Queue('lopri', task_exchange, routing_key='lopri'...
9
323
kombu
examples/simple_task_queue/tasks.py
.py
from __future__ import annotations def hello_task(who='world'): print(f'Hello {who}')
6
92
kombu
examples/experimental/async_consume.py
.py
#!/usr/bin/env python3 from __future__ import annotations from kombu import Connection, Consumer, Exchange, Producer, Queue from kombu.asynchronous import Hub hub = Hub() exchange = Exchange('asynt') queue = Queue('asynt', exchange, 'asynt') def send_message(conn): producer = Producer(conn) producer.publis...
32
746
kombu
examples/rpc-tut6/rpc_client.py
.py
#!/usr/bin/env python3 from __future__ import annotations from kombu import Connection, Consumer, Producer, Queue, uuid class FibonacciRpcClient: def __init__(self, connection): self.connection = connection self.callback_queue = Queue(uuid(), exclusive=True, auto_delete=True) def on_respon...
48
1,447
kombu
examples/rpc-tut6/rpc_server.py
.py
#!/usr/bin/env python3 from __future__ import annotations from kombu import Connection, Queue from kombu.mixins import ConsumerProducerMixin rpc_queue = Queue('rpc_queue') def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n - 1) + fib(n - 2) class Worker(C...
60
1,332
rq
rq/types.py
.py
from __future__ import annotations from collections.abc import Callable from types import TracebackType from typing import TYPE_CHECKING, Any, TypeVar if TYPE_CHECKING: from typing import TypeAlias from redis import Redis from .job import Dependency, Job FunctionReferenceType = TypeVar('FunctionRefere...
32
973
rq
rq/dependency.py
.py
from collections.abc import Iterable from redis.client import Pipeline from redis.exceptions import WatchError from .job import Job class Dependency: @classmethod def get_jobs_with_met_dependencies(cls, jobs: Iterable['Job'], pipeline: Pipeline): jobs_with_met_dependencies = [] jobs_with_unm...
28
1,000
rq
rq/utils.py
.py
""" Miscellaneous helper functions. The formatter for ANSI colored console output is heavily based on Pygments terminal colorizing code, originally by Georg Brandl. """ from __future__ import annotations import calendar import datetime import importlib import inspect import json import logging import numbers import ...
599
18,526
rq
rq/maintenance.py
.py
import warnings from typing import TYPE_CHECKING from .intermediate_queue import IntermediateQueue from .queue import Queue if TYPE_CHECKING: from .worker import BaseWorker def clean_intermediate_queue(worker: 'BaseWorker', queue: Queue) -> None: """ Check whether there are any jobs stuck in the interme...
27
940
rq
rq/exceptions.py
.py
class NoSuchJobError(Exception): pass class NoSuchGroupError(Exception): pass class DeserializationError(Exception): pass class InvalidJobDependency(Exception): pass class DuplicateJobError(Exception): pass class InvalidJobOperationError(Exception): pass class InvalidJobOperation(Exc...
59
915
rq
rq/intermediate_queue.py
.py
from __future__ import annotations from datetime import datetime, timedelta, timezone from typing import TYPE_CHECKING from redis import Redis from rq.utils import now if TYPE_CHECKING: from .queue import Queue from .worker import BaseWorker class IntermediateQueue: def __init__(self, queue_key: str, ...
120
3,845
rq
rq/scheduler.py
.py
from __future__ import annotations import logging import os import signal import socket import time import traceback from collections.abc import Iterable from datetime import datetime from enum import Enum from multiprocessing import Process, get_context from multiprocessing.process import BaseProcess from uuid import...
337
12,809
rq
rq/__init__.py
.py
# ruff: noqa: F401 from .job import Callback, Retry, cancel_job, get_current_job, requeue_job from .queue import Queue from .rate_limit import RateLimit from .repeat import Repeat from .version import VERSION from .webhook import Webhook from .worker import SimpleWorker, SpawnWorker, Worker __all__ = [ 'Callback',...
26
531
rq
rq/group.py
.py
from __future__ import annotations from collections.abc import Iterable from uuid import uuid4 from redis import Redis from redis.client import Pipeline from . import Queue from .exceptions import NoSuchGroupError from .job import Job from .queue import EnqueueData from .utils import as_text class Group: """A ...
129
4,745
rq
rq/serializers.py
.py
from __future__ import annotations import json import pickle from collections.abc import Callable from functools import partial from typing import Any, ClassVar, Protocol, cast, runtime_checkable from .utils import import_attribute @runtime_checkable class Serializer(Protocol): def dumps(self, obj: Any, /) -> b...
68
2,040
rq
rq/registry.py
.py
from __future__ import annotations import calendar import logging import time import warnings from collections.abc import Sequence from datetime import datetime, timedelta, timezone from typing import TYPE_CHECKING, Any, cast from redis.exceptions import WatchError from rq.serializers import resolve_serializer from...
744
30,286
rq
rq/rate_limit.py
.py
from __future__ import annotations from datetime import datetime from functools import cached_property from redis import Redis from redis.client import Pipeline from .utils import as_text, current_timestamp, now, utcformat class RateLimit: """Defines a concurrency-based rate limit for jobs. Args: ...
272
11,056
rq
rq/worker_registration.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from redis import Redis from redis.client import Pipeline from .queue import Queue from .worker import BaseWorker from rq.utils import split_list from .utils import as_text WORKERS_BY_QUEUE_KEY = 'rq:workers:%s' ...
108
3,145
rq
rq/defaults.py
.py
DEFAULT_JOB_CLASS = 'rq.job.Job' """ The path for the default Job class to use. Defaults to the main `Job` class within the `rq.job` module """ DEFAULT_QUEUE_CLASS = 'rq.Queue' """ The path for the default Queue class to use. Defaults to the main `Queue` class within the `rq.queue` module """ DEFAULT_WORKER_CLASS =...
114
3,222
rq
rq/connections.py
.py
from redis import Connection as RedisConnection from redis import Redis class NoRedisConnectionException(Exception): pass # redis-py >= 8 may add maintenance-notification handlers and other derived # connection metadata to connection_kwargs. Those values describe the current # pool's internal state, and some co...
40
1,642
rq
rq/timeouts.py
.py
import ctypes import signal import threading class BaseTimeoutException(Exception): """Base exception for timeouts.""" pass class JobTimeoutException(BaseTimeoutException): """Raised when a job takes longer to complete than the allowed maximum timeout value. """ pass class HorseMonitorTi...
132
4,331
rq
rq/cron.py
.py
from __future__ import annotations import importlib.util import json import logging import os import signal import socket import sys import time import uuid from collections.abc import Callable, Sequence from datetime import datetime, timedelta, timezone from typing import Any from croniter import croniter from redis...
718
27,978
rq
rq/job.py
.py
from __future__ import annotations import asyncio import inspect import json import logging import re import warnings import zlib from collections.abc import Callable, Iterable, Mapping, Sequence from contextvars import ContextVar from datetime import datetime, timedelta from enum import Enum from typing import TYPE_C...
2,022
83,220
rq
rq/decorators.py
.py
from __future__ import annotations from collections.abc import Callable, Sequence from functools import wraps from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from redis import Redis from .job import Retry from .defaults import DEFAULT_RESULT_TTL from .job import Callback from .queue import Queue fro...
134
5,357
rq
rq/executions.py
.py
from __future__ import annotations import logging from datetime import datetime, timezone from typing import TYPE_CHECKING, Any from uuid import uuid4 from redis import Redis if TYPE_CHECKING: from redis.client import Pipeline from .worker.base import BaseWorker from .job import Job from .registry import B...
251
10,215
rq
rq/suspension.py
.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from redis import Redis from rq.worker import BaseWorker WORKERS_SUSPENDED = 'rq:suspended' def is_suspended(connection: Redis, worker: BaseWorker | None = None): """Checks whether a Worker is suspended on a given c...
52
1,356
rq
rq/cron_scheduler_registry.py
.py
from __future__ import annotations import time from typing import TYPE_CHECKING from redis import Redis from redis.client import Pipeline from .exceptions import DuplicateSchedulerError, SchedulerNotFound if TYPE_CHECKING: from .cron import CronScheduler def get_registry_key() -> str: """Get the Redis key...
97
3,366
rq
rq/queue.py
.py
from __future__ import annotations import logging import sys import uuid import warnings from collections import defaultdict, namedtuple from collections.abc import Callable, Iterable, Sequence from datetime import datetime, timedelta from functools import total_ordering from typing import ( TYPE_CHECKING, Any...
1,777
70,472
rq
rq/local.py
.py
# ruff: noqa: E731 """ werkzeug.local ~~~~~~~~~~~~~~ This module implements context-local objects. :copyright: (c) 2011 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ # Since each thread has its own greenlet we can just use those as identifiers # for the context....
433
12,808
rq
rq/scripts.py
.py
import calendar import logging import time from datetime import timedelta, timezone from typing import Any from .exceptions import DuplicateJobError from .logutils import blue, green logger = logging.getLogger('rq.scripts') # Lua script for atomic unique enqueue: check existence, save job, push to queue UNIQUE_ENQUE...
205
6,565
rq
rq/command.py
.py
import json import os import signal from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from redis import Redis from .worker import BaseWorker from rq.exceptions import InvalidJobOperation from rq.executions import Execution from rq.job import Job PUBSUB_CHANNEL_TEMPLATE = 'rq:pubsub:%s' def send_comm...
177
5,504
rq
rq/repeat.py
.py
from __future__ import annotations from collections.abc import Iterable from dataclasses import dataclass from datetime import datetime, timedelta from typing import TYPE_CHECKING if TYPE_CHECKING: from redis.client import Pipeline from .job import Job from .queue import Queue @dataclass class Repeat: ...
119
4,304