rrq 0.3.6__py3-none-any.whl → 0.3.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rrq
3
- Version: 0.3.6
3
+ Version: 0.3.7
4
4
  Summary: RRQ is a Python library for creating reliable job queues using Redis and asyncio
5
5
  Project-URL: Homepage, https://github.com/getresq/rrq
6
6
  Project-URL: Bug Tracker, https://github.com/getresq/rrq/issues
@@ -29,18 +29,6 @@ Description-Content-Type: text/markdown
29
29
 
30
30
  RRQ is a Python library for creating reliable job queues using Redis and `asyncio`, inspired by [ARQ (Async Redis Queue)](https://github.com/samuelcolvin/arq). It focuses on providing at-least-once job processing semantics with features like automatic retries, job timeouts, dead-letter queues, and graceful worker shutdown.
31
31
 
32
- ## Core Components
33
-
34
- * **`RRQClient` (`client.py`)**: Used to enqueue jobs onto specific queues. Supports deferring jobs (by time delta or specific datetime), assigning custom job IDs, and enforcing job uniqueness via keys.
35
- * **`RRQWorker` (`worker.py`)**: The process that polls queues, fetches jobs, executes the corresponding handler functions, and manages the job lifecycle based on success, failure, retries, or timeouts. Handles graceful shutdown via signals (SIGINT, SIGTERM).
36
- * **`JobRegistry` (`registry.py`)**: A simple registry to map string function names (used when enqueuing) to the actual asynchronous handler functions the worker should execute.
37
- * **`JobStore` (`store.py`)**: An abstraction layer handling all direct interactions with Redis. It manages job definitions (Hashes), queues (Sorted Sets), processing locks (Strings with TTL), unique job locks, and worker health checks.
38
- * **`Job` (`job.py`)**: A Pydantic model representing a job, containing its ID, handler name, arguments, status, retry counts, timestamps, results, etc.
39
- * **`JobStatus` (`job.py`)**: An Enum defining the possible states of a job (`PENDING`, `ACTIVE`, `COMPLETED`, `FAILED`, `RETRYING`).
40
- * **`RRQSettings` (`settings.py`)**: A Pydantic `BaseSettings` model for configuring RRQ behavior (Redis DSN, queue names, timeouts, retry policies, concurrency, etc.). Loadable from environment variables (prefix `RRQ_`).
41
- * **`constants.py`**: Defines shared constants like Redis key prefixes and default configuration values.
42
- * **`exc.py`**: Defines custom exceptions, notably `RetryJob` which handlers can raise to explicitly request a retry, potentially with a custom delay.
43
-
44
32
  ## Key Features
45
33
 
46
34
  * **At-Least-Once Semantics**: Uses Redis locks to ensure a job is processed by only one worker at a time. If a worker crashes or shuts down mid-processing, the lock expires, and the job *should* be re-processed (though re-queueing on unclean shutdown isn't implemented here yet - graceful shutdown *does* re-queue).
@@ -52,8 +40,10 @@ RRQ is a Python library for creating reliable job queues using Redis and `asynci
52
40
  * **Graceful Shutdown**: Workers listen for SIGINT/SIGTERM and attempt to finish active jobs within a grace period before exiting. Interrupted jobs are re-queued.
53
41
  * **Worker Health Checks**: Workers periodically update a health key in Redis with a TTL, allowing monitoring systems to track active workers.
54
42
  * **Deferred Execution**: Jobs can be scheduled to run at a future time using `_defer_by` or `_defer_until`.
55
- *Note: Using deferral with a specific `_job_id` will effectively reschedule the job associated with that ID to the new time, overwriting its previous definition and score. It does not create multiple distinct scheduled jobs with the same ID.*
56
- *To batch multiple enqueue calls into a single deferred job (and prevent duplicates within the defer window), combine `_unique_key` with `_defer_by`. For example:*
43
+
44
+ - Using deferral with a specific `_job_id` will effectively reschedule the job associated with that ID to the new time, overwriting its previous definition and score. It does not create multiple distinct scheduled jobs with the same ID.
45
+
46
+ - To batch multiple enqueue calls into a single deferred job (and prevent duplicates within the defer window), combine `_unique_key` with `_defer_by`. For example:
57
47
 
58
48
  ```python
59
49
  await client.enqueue(
@@ -129,6 +119,9 @@ if __name__ == "__main__":
129
119
 
130
120
  **5. Run a Worker:**
131
121
 
122
+ Note: You don't need to run a worker as the Command Line Interface `rrq` is used for
123
+ this purpose.
124
+
132
125
  ```python
133
126
  # worker_script.py
134
127
  from rrq.worker import RRQWorker
@@ -145,61 +138,47 @@ if __name__ == "__main__":
145
138
 
146
139
  You can run multiple instances of `worker_script.py` for concurrent processing.
147
140
 
148
- ## Configuration
149
-
150
- RRQ behavior is configured via the `RRQSettings` object, which loads values from environment variables prefixed with `RRQ_` by default. Key settings include:
151
-
152
- * `RRQ_REDIS_DSN`: Connection string for Redis.
153
- * `RRQ_DEFAULT_QUEUE_NAME`: Default queue name.
154
- * `RRQ_DEFAULT_MAX_RETRIES`: Default retry limit.
155
- * `RRQ_DEFAULT_JOB_TIMEOUT_SECONDS`: Default job timeout.
156
- * `RRQ_WORKER_CONCURRENCY`: Max concurrent jobs per worker.
157
- * ... and others (see `settings.py`).
158
-
159
- ## RRQ CLI
160
-
161
- RRQ provides a command-line interface (CLI) for interacting with the job queue system. The `rrq` CLI allows you to manage workers, check system health, and get statistics about queues and jobs.
141
+ ## Command Line Interface
142
+
143
+ RRQ provides a command-line interface (CLI) for managing workers and performing health checks:
144
+
145
+ - **`rrq worker run`** - Run an RRQ worker process.
146
+ - `--settings` (optional): Specify the Python path to your settings object (e.g., `myapp.worker_config.rrq_settings`). If not provided, it will use the `RRQ_SETTINGS` environment variable or default to a basic `RRQSettings` object.
147
+ - `--queue` (optional, multiple): Specify queue(s) to poll. Defaults to the `default_queue_name` in settings.
148
+ - `--burst` (flag): Run the worker in burst mode to process one job or batch and then exit.
149
+ - **`rrq worker watch`** - Run an RRQ worker with auto-restart on file changes.
150
+ - `--path` (optional): Directory path to watch for changes. Defaults to the current directory.
151
+ - `--settings` (optional): Same as above.
152
+ - `--queue` (optional, multiple): Same as above.
153
+ - **`rrq check`** - Perform a health check on active RRQ workers.
154
+ - `--settings` (optional): Same as above.
155
+ - **`rrq dlq requeue`** - Requeue jobs from the dead letter queue back into a live queue.
156
+ - `--settings` (optional): Same as above.
157
+ - `--dlq-name` (optional): Name of the DLQ (without prefix). Defaults to `default_dlq_name` in settings.
158
+ - `--queue` (optional): Target queue name (without prefix). Defaults to `default_queue_name` in settings.
159
+ - `--limit` (optional): Maximum number of DLQ jobs to requeue; all if not set.
162
160
 
163
- ### Usage
164
-
165
- ```bash
166
- rrq <command> [options]
167
- ```
168
-
169
- ### Commands
170
-
171
- - **`worker run`**: Run an RRQ worker process to process jobs from queues.
172
- ```bash
173
- rrq worker run [--burst] --settings <settings_path>
174
- ```
175
- - `--burst`: Run in burst mode (process one job/batch then exit).
176
- - `--settings`: Python settings path for application worker settings (e.g., `myapp.worker_config.rrq_settings`).
177
-
178
- - **`worker watch`**: Run an RRQ worker with auto-restart on file changes in a specified directory.
179
- ```bash
180
- rrq worker watch [--path <directory>] --settings <settings_path>
181
- ```
182
- - `--path`: Directory to watch for changes (default: current directory).
183
- - `--settings`: Python settings path for application worker settings.
184
-
185
- - **`check`**: Perform a health check on active RRQ workers.
186
- ```bash
187
- rrq check --settings <settings_path>
188
- ```
189
- - `--settings`: Python settings path for application settings.
161
+ ## Configuration
190
162
 
163
+ RRQ can be configured in several ways, with the following precedence:
191
164
 
192
- ### Configuration
165
+ 1. **Command-Line Argument (`--settings`)**: Directly specify the settings object path via the CLI. This takes the highest precedence.
166
+ 2. **Environment Variable (`RRQ_SETTINGS`)**: Set the `RRQ_SETTINGS` environment variable to point to your settings object path. Used if `--settings` is not provided.
167
+ 3. **Default Settings**: If neither of the above is provided, RRQ will instantiate a default `RRQSettings` object, which can still be influenced by environment variables starting with `RRQ_`.
168
+ 4. **Environment Variables (Prefix `RRQ_`)**: Individual settings can be overridden by environment variables starting with `RRQ_`, which are automatically picked up by the `RRQSettings` object.
169
+ 5. **.env File**: If `python-dotenv` is installed, RRQ will attempt to load a `.env` file from the current working directory or parent directories. System environment variables take precedence over `.env` variables.
193
170
 
194
- The CLI uses the same `RRQSettings` as the library, loading configuration from environment variables prefixed with `RRQ_`. You can also specify the settings via the `--settings` option for commands.
171
+ **Important Note on `job_registry`**: The `job_registry` attribute in your `RRQSettings` object is **critical** for RRQ to function. It must be an instance of `JobRegistry` and is used to register job handlers. Without a properly configured `job_registry`, workers will not know how to process jobs, and most operations will fail. Ensure it is set in your settings object to map job names to their respective handler functions.
195
172
 
196
- ```bash
197
- rrq worker run --settings myapp.worker_config.rrq_settings
198
- ```
199
173
 
200
- ### Help
174
+ ## Core Components
201
175
 
202
- For detailed help on any command, use:
203
- ```bash
204
- rrq <command> --help
205
- ```
176
+ * **`RRQClient` (`client.py`)**: Used to enqueue jobs onto specific queues. Supports deferring jobs (by time delta or specific datetime), assigning custom job IDs, and enforcing job uniqueness via keys.
177
+ * **`RRQWorker` (`worker.py`)**: The process that polls queues, fetches jobs, executes the corresponding handler functions, and manages the job lifecycle based on success, failure, retries, or timeouts. Handles graceful shutdown via signals (SIGINT, SIGTERM).
178
+ * **`JobRegistry` (`registry.py`)**: A simple registry to map string function names (used when enqueuing) to the actual asynchronous handler functions the worker should execute.
179
+ * **`JobStore` (`store.py`)**: An abstraction layer handling all direct interactions with Redis. It manages job definitions (Hashes), queues (Sorted Sets), processing locks (Strings with TTL), unique job locks, and worker health checks.
180
+ * **`Job` (`job.py`)**: A Pydantic model representing a job, containing its ID, handler name, arguments, status, retry counts, timestamps, results, etc.
181
+ * **`JobStatus` (`job.py`)**: An Enum defining the possible states of a job (`PENDING`, `ACTIVE`, `COMPLETED`, `FAILED`, `RETRYING`).
182
+ * **`RRQSettings` (`settings.py`)**: A Pydantic `BaseSettings` model for configuring RRQ behavior (Redis DSN, queue names, timeouts, retry policies, concurrency, etc.). Loadable from environment variables (prefix `RRQ_`).
183
+ * **`constants.py`**: Defines shared constants like Redis key prefixes and default configuration values.
184
+ * **`exc.py`**: Defines custom exceptions, notably `RetryJob` which handlers can raise to explicitly request a retry, potentially with a custom delay.
@@ -8,8 +8,8 @@ rrq/registry.py,sha256=E9W_zx3QiKTBwMOGearaNpDKBDB87JIn0RlMQ3sAcP0,2925
8
8
  rrq/settings.py,sha256=BPKP4XjG7z475gqRgHZt4-IvvOs8uZefq4fPfD2Bepk,4350
9
9
  rrq/store.py,sha256=teO0Af8hzBiu7-dFn6_2lz5X90LAZXmtg0VDZuQoAwk,24972
10
10
  rrq/worker.py,sha256=y0UTziZVh4QbOPv24b8cqbm_xDBM0HtJLwPNYsJPWnE,40706
11
- rrq-0.3.6.dist-info/METADATA,sha256=MKJ-uoveQQVVI4p_RhRA1Kk-KN9_J348gGYY572HUY0,9224
12
- rrq-0.3.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- rrq-0.3.6.dist-info/entry_points.txt,sha256=f8eFjk2ygDSyu9USwXGj5IM8xeyQqZgDa1rSrCj4Mis,36
14
- rrq-0.3.6.dist-info/licenses/LICENSE,sha256=XDvu5hKdS2-_ByiSj3tiu_3zSsrXXoJsgbILGoMpKCw,554
15
- rrq-0.3.6.dist-info/RECORD,,
11
+ rrq-0.3.7.dist-info/METADATA,sha256=fqMod1pTxebf7d4fCh5vRK0o9gkD4OAYg-02TNHJfN4,10193
12
+ rrq-0.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ rrq-0.3.7.dist-info/entry_points.txt,sha256=f8eFjk2ygDSyu9USwXGj5IM8xeyQqZgDa1rSrCj4Mis,36
14
+ rrq-0.3.7.dist-info/licenses/LICENSE,sha256=XDvu5hKdS2-_ByiSj3tiu_3zSsrXXoJsgbILGoMpKCw,554
15
+ rrq-0.3.7.dist-info/RECORD,,
File without changes