rrq 0.3.5__py3-none-any.whl → 0.3.6__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.
- rrq/cli.py +30 -18
- {rrq-0.3.5.dist-info → rrq-0.3.6.dist-info}/METADATA +1 -1
- {rrq-0.3.5.dist-info → rrq-0.3.6.dist-info}/RECORD +6 -6
- {rrq-0.3.5.dist-info → rrq-0.3.6.dist-info}/WHEEL +0 -0
- {rrq-0.3.5.dist-info → rrq-0.3.6.dist-info}/entry_points.txt +0 -0
- {rrq-0.3.5.dist-info → rrq-0.3.6.dist-info}/licenses/LICENSE +0 -0
rrq/cli.py
CHANGED
|
@@ -18,6 +18,14 @@ from .settings import RRQSettings
|
|
|
18
18
|
from .store import JobStore
|
|
19
19
|
from .worker import RRQWorker
|
|
20
20
|
|
|
21
|
+
# Attempt to import dotenv components for .env file loading
|
|
22
|
+
try:
|
|
23
|
+
from dotenv import find_dotenv, load_dotenv
|
|
24
|
+
|
|
25
|
+
DOTENV_AVAILABLE = True
|
|
26
|
+
except ImportError:
|
|
27
|
+
DOTENV_AVAILABLE = False
|
|
28
|
+
|
|
21
29
|
logger = logging.getLogger(__name__)
|
|
22
30
|
|
|
23
31
|
|
|
@@ -28,12 +36,21 @@ def _load_app_settings(settings_object_path: str | None = None) -> RRQSettings:
|
|
|
28
36
|
If the environment variable is not set, will create a default settings object.
|
|
29
37
|
RRQ Setting objects, automatically pick up ENVIRONMENT variables starting with RRQ_.
|
|
30
38
|
|
|
39
|
+
This function will also attempt to load a .env file if python-dotenv is installed
|
|
40
|
+
and a .env file is found. System environment variables take precedence over .env variables.
|
|
41
|
+
|
|
31
42
|
Args:
|
|
32
43
|
settings_object_path: A string representing the path to the settings object. (e.g. "myapp.worker_config.rrq_settings").
|
|
33
44
|
|
|
34
45
|
Returns:
|
|
35
46
|
The RRQSettings object.
|
|
36
47
|
"""
|
|
48
|
+
if DOTENV_AVAILABLE:
|
|
49
|
+
dotenv_path = find_dotenv(usecwd=True)
|
|
50
|
+
if dotenv_path:
|
|
51
|
+
logger.debug(f"Loading .env file at: {dotenv_path}...")
|
|
52
|
+
load_dotenv(dotenv_path=dotenv_path, override=False)
|
|
53
|
+
|
|
37
54
|
try:
|
|
38
55
|
if settings_object_path is None:
|
|
39
56
|
settings_object_path = os.getenv("RRQ_SETTINGS")
|
|
@@ -153,12 +170,10 @@ def start_rrq_worker_subprocess(
|
|
|
153
170
|
) -> subprocess.Popen | None:
|
|
154
171
|
"""Start an RRQ worker process, optionally for specific queues."""
|
|
155
172
|
command = ["rrq", "worker", "run"]
|
|
173
|
+
|
|
156
174
|
if settings_object_path:
|
|
157
175
|
command.extend(["--settings", settings_object_path])
|
|
158
|
-
|
|
159
|
-
raise ValueError(
|
|
160
|
-
"start_rrq_worker_subprocess called without settings_object_path!"
|
|
161
|
-
)
|
|
176
|
+
|
|
162
177
|
# Add queue filters if specified
|
|
163
178
|
if queues:
|
|
164
179
|
for q in queues:
|
|
@@ -220,16 +235,6 @@ async def watch_rrq_worker_impl(
|
|
|
220
235
|
settings_object_path: str | None = None,
|
|
221
236
|
queues: list[str] | None = None,
|
|
222
237
|
) -> None:
|
|
223
|
-
if not settings_object_path:
|
|
224
|
-
click.echo(
|
|
225
|
-
click.style(
|
|
226
|
-
"ERROR: 'rrq worker watch' requires --settings to be specified.",
|
|
227
|
-
fg="red",
|
|
228
|
-
),
|
|
229
|
-
err=True,
|
|
230
|
-
)
|
|
231
|
-
sys.exit(1)
|
|
232
|
-
|
|
233
238
|
abs_watch_path = os.path.abspath(watch_path)
|
|
234
239
|
click.echo(
|
|
235
240
|
f"Watching for file changes in {abs_watch_path} to restart RRQ worker (app settings: {settings_object_path})..."
|
|
@@ -295,7 +300,7 @@ def rrq():
|
|
|
295
300
|
"""RRQ: Reliable Redis Queue Command Line Interface.
|
|
296
301
|
|
|
297
302
|
Provides tools for running RRQ workers, checking system health,
|
|
298
|
-
and managing jobs. Requires an application-specific
|
|
303
|
+
and managing jobs. Requires an application-specific settings object
|
|
299
304
|
for most operations.
|
|
300
305
|
"""
|
|
301
306
|
pass
|
|
@@ -329,6 +334,7 @@ def worker_cli():
|
|
|
329
334
|
help=(
|
|
330
335
|
"Python settings path for application worker settings "
|
|
331
336
|
"(e.g., myapp.worker_config.rrq_settings). "
|
|
337
|
+
"Alternatively, this can be specified as RRQ_SETTINGS env variable. "
|
|
332
338
|
"The specified settings object must include a `job_registry: JobRegistry`."
|
|
333
339
|
),
|
|
334
340
|
)
|
|
@@ -337,7 +343,9 @@ def worker_run_command(
|
|
|
337
343
|
queues: tuple[str, ...],
|
|
338
344
|
settings_object_path: str,
|
|
339
345
|
):
|
|
340
|
-
"""Run an RRQ worker process.
|
|
346
|
+
"""Run an RRQ worker process.
|
|
347
|
+
Requires an application-specific settings object.
|
|
348
|
+
"""
|
|
341
349
|
rrq_settings = _load_app_settings(settings_object_path)
|
|
342
350
|
|
|
343
351
|
# Determine queues to poll
|
|
@@ -418,7 +426,9 @@ def worker_watch_command(
|
|
|
418
426
|
settings_object_path: str,
|
|
419
427
|
queues: tuple[str, ...],
|
|
420
428
|
):
|
|
421
|
-
"""Run the RRQ worker with auto-restart on file changes in PATH.
|
|
429
|
+
"""Run the RRQ worker with auto-restart on file changes in PATH.
|
|
430
|
+
Requires an application-specific settings object.
|
|
431
|
+
"""
|
|
422
432
|
# Run watch with optional queue filters
|
|
423
433
|
asyncio.run(
|
|
424
434
|
watch_rrq_worker_impl(
|
|
@@ -446,7 +456,9 @@ def worker_watch_command(
|
|
|
446
456
|
),
|
|
447
457
|
)
|
|
448
458
|
def check_command(settings_object_path: str):
|
|
449
|
-
"""Perform a health check on active RRQ worker(s).
|
|
459
|
+
"""Perform a health check on active RRQ worker(s).
|
|
460
|
+
Requires an application-specific settings object.
|
|
461
|
+
"""
|
|
450
462
|
click.echo("Performing RRQ health check...")
|
|
451
463
|
healthy = asyncio.run(
|
|
452
464
|
check_health_async_impl(settings_object_path=settings_object_path)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rrq
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
rrq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
rrq/cli.py,sha256=
|
|
2
|
+
rrq/cli.py,sha256=_LbaAH_w2a0VNRR0EctuE4afl-wccvMY2w2VbehFDEQ,16980
|
|
3
3
|
rrq/client.py,sha256=5_bmZ05LKIfY9WFSKU-nYawEupsnrnHT2HewXfC2Ahg,7831
|
|
4
4
|
rrq/constants.py,sha256=F_uZgBI3h00MctnEjBjiCGMrg5jUaz5Bz9I1vkyqNrs,1654
|
|
5
5
|
rrq/exc.py,sha256=NJq3C7pUfcd47AB8kghIN8vdY0l90UrsHQEg4McBHP8,1281
|
|
@@ -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.
|
|
12
|
-
rrq-0.3.
|
|
13
|
-
rrq-0.3.
|
|
14
|
-
rrq-0.3.
|
|
15
|
-
rrq-0.3.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|