queuerPy 0.16.0__tar.gz → 0.17.0__tar.gz
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.
- {queuerpy-0.16.0/queuerPy.egg-info → queuerpy-0.17.0}/PKG-INFO +82 -7
- {queuerpy-0.16.0 → queuerpy-0.17.0}/README.md +81 -6
- {queuerpy-0.16.0 → queuerpy-0.17.0}/_version.py +1 -1
- {queuerpy-0.16.0 → queuerpy-0.17.0}/pyproject.toml +2 -2
- {queuerpy-0.16.0 → queuerpy-0.17.0/queuerPy.egg-info}/PKG-INFO +82 -7
- {queuerpy-0.16.0 → queuerpy-0.17.0}/LICENSE +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/MANIFEST.in +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/__init__.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/__init__.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/broadcaster.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/listener.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/retryer.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/runner.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/scheduler.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/core/ticker.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/database/__init__.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/database/db_job.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/database/db_listener.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/database/db_master.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/database/db_worker.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/__init__.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/database.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/error.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/logging.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/sql.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/helper/task.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/__init__.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/batch_job.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/connection.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/job.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/master.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/options.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/options_on_error.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/task.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/model/worker.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/py.typed +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuerPy.egg-info/SOURCES.txt +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuerPy.egg-info/dependency_links.txt +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuerPy.egg-info/requires.txt +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuerPy.egg-info/top_level.txt +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_global.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_job.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_listener.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_master.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_next_interval.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/queuer_task.py +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/setup.cfg +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/sql/job.sql +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/sql/master.sql +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/sql/notify.sql +0 -0
- {queuerpy-0.16.0 → queuerpy-0.17.0}/sql/worker.sql +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queuerPy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: A Python implementation of the queuer system - a job queuing and processing system with PostgreSQL backend
|
|
5
5
|
Author-email: Simon Herrmann <siherrmann@users.noreply.github.com>
|
|
6
6
|
Maintainer-email: Simon Herrmann <siherrmann@users.noreply.github.com>
|
|
@@ -43,9 +43,10 @@ Dynamic: license-file
|
|
|
43
43
|
|
|
44
44
|
# queuerPy
|
|
45
45
|
|
|
46
|
+
[](https://pypi.org/project/queuerPy/)
|
|
46
47
|
[](https://www.python.org/)
|
|
47
|
-
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
48
48
|

|
|
49
|
+
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
49
50
|
|
|
50
51
|
Python port of the queuer package - a queueing system based on PostgreSQL.
|
|
51
52
|
|
|
@@ -97,9 +98,15 @@ def example_task():
|
|
|
97
98
|
That's easy, right? Adding a job is just as easy:
|
|
98
99
|
|
|
99
100
|
```python
|
|
100
|
-
# Add a job to the queue
|
|
101
|
+
# Add a job to the queue with positional arguments
|
|
101
102
|
job = q.add_job(example_task, 5, "12")
|
|
102
103
|
print(f"Job added: {job.rid}")
|
|
104
|
+
|
|
105
|
+
# Add a job with keyword arguments (kwargs)
|
|
106
|
+
job = q.add_job(example_task, paramKeyed1="test", debug=True)
|
|
107
|
+
|
|
108
|
+
# Add a job with both positional and keyword arguments
|
|
109
|
+
job = q.add_job(example_task, 5, "12", paramKeyed1="test", debug=True)
|
|
103
110
|
```
|
|
104
111
|
|
|
105
112
|
In the initialisation of the queuer the existence of the necessary database tables is checked and if they don't exist they get created. The database is configured with these environment variables:
|
|
@@ -199,6 +206,72 @@ This method handles the registration of a task, making the worker able to pick u
|
|
|
199
206
|
|
|
200
207
|
---
|
|
201
208
|
|
|
209
|
+
## add_job
|
|
210
|
+
|
|
211
|
+
The `add_job` method adds a new job to the queue for execution. Jobs are units of work that will be processed by the queuer.
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
def add_job(
|
|
215
|
+
self,
|
|
216
|
+
task: Union[Callable, str],
|
|
217
|
+
*parameters: Any,
|
|
218
|
+
**parameters_keyed: Any
|
|
219
|
+
) -> Job
|
|
220
|
+
|
|
221
|
+
def add_job_with_options(
|
|
222
|
+
self,
|
|
223
|
+
options: Optional[Options],
|
|
224
|
+
task: Union[Callable, str],
|
|
225
|
+
*parameters: Any,
|
|
226
|
+
**parameters_keyed: Any
|
|
227
|
+
) -> Job
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- `task`: A `Callable` or `str` representing the task to execute. If a callable, it must be registered with `add_task` first.
|
|
231
|
+
- `options`: Optional `Options` for custom error handling or scheduling behavior. Only available in `add_job_with_options()`.
|
|
232
|
+
- `*parameters`: Positional arguments to pass to the task function.
|
|
233
|
+
- `**parameters_keyed`: Keyword arguments to pass to the task function (Python-specific feature).
|
|
234
|
+
|
|
235
|
+
**Examples:**
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
# Job with both positional and keyword arguments
|
|
239
|
+
job = queuer.add_job(my_task, "arg1", paramKeyed1="test", paramKeyed2=1)
|
|
240
|
+
|
|
241
|
+
# Job with custom options (requires add_job_with_options)
|
|
242
|
+
options = Options(on_error=OnError(max_retries=5))
|
|
243
|
+
job = queuer.add_job_with_options(options, my_task, "arg1", debug=True)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Note:** Keyword arguments (`**parameters_keyed`) are stored separately in the database and enable Python functions to be called with named parameters. This is useful for optional parameters, default values, and improved code clarity. Go jobs continue to use only positional parameters.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## add_jobs
|
|
251
|
+
|
|
252
|
+
The `add_jobs` method allows efficient batch insertion of multiple jobs at once.
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
def add_jobs(self, batch_jobs: List[BatchJob]) -> List[UUID]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- `batch_jobs`: A list of `BatchJob` instances to insert.
|
|
259
|
+
|
|
260
|
+
**Example:**
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from model.batch_job import BatchJob
|
|
264
|
+
|
|
265
|
+
batch = [
|
|
266
|
+
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
267
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
268
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
269
|
+
]
|
|
270
|
+
job_rids = queuer.add_jobs(batch)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
202
275
|
## add_next_interval_func
|
|
203
276
|
|
|
204
277
|
The `add_next_interval_func` method registers a custom function that determines the next execution time for scheduled jobs. This is useful for implementing complex scheduling logic beyond simple fixed intervals.
|
|
@@ -296,19 +369,20 @@ class Schedule:
|
|
|
296
369
|
### Job Management
|
|
297
370
|
|
|
298
371
|
```python
|
|
299
|
-
# Add a
|
|
300
|
-
job = queuer.add_job(my_task, param1, param2)
|
|
372
|
+
# Add a job with both positional and keyword arguments
|
|
373
|
+
job = queuer.add_job(my_task, param1, param2, paramKeyed1="test", paramKeyed2=1)
|
|
301
374
|
|
|
302
375
|
# Add a job with custom options
|
|
303
376
|
from model.options import Options, OnError
|
|
304
377
|
options = Options(on_error=OnError(max_retries=5, timeout=60.0))
|
|
305
|
-
job = queuer.add_job_with_options(options, my_task, param1)
|
|
378
|
+
job = queuer.add_job_with_options(options, my_task, param1, paramKeyed1="test")
|
|
306
379
|
|
|
307
380
|
# Add multiple jobs as a batch
|
|
308
381
|
from model.batch_job import BatchJob
|
|
309
382
|
batch = [
|
|
310
383
|
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
311
|
-
BatchJob(task=my_task, parameters=[2, "b"
|
|
384
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
385
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
312
386
|
]
|
|
313
387
|
queuer.add_jobs(batch)
|
|
314
388
|
|
|
@@ -335,6 +409,7 @@ worker_jobs = queuer.get_jobs_by_worker_rid(worker.rid)
|
|
|
335
409
|
|
|
336
410
|
# ⭐ Features
|
|
337
411
|
|
|
412
|
+
- **Keyword Arguments Support**: Python functions can use both positional arguments (`*args`) and keyword arguments (`**kwargs`), while maintaining compatibility with Go jobs that use only positional parameters.
|
|
338
413
|
- **Async/Await Support**: Full asyncio integration with threading fallbacks.
|
|
339
414
|
- **PostgreSQL NOTIFY/LISTEN**: Real-time job notifications without polling overhead.
|
|
340
415
|
- **Batch Job Processing**: Insert job batches efficiently using PostgreSQL's `COPY FROM` feature.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# queuerPy
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/queuerPy/)
|
|
3
4
|
[](https://www.python.org/)
|
|
4
|
-
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
5
5
|

|
|
6
|
+
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
6
7
|
|
|
7
8
|
Python port of the queuer package - a queueing system based on PostgreSQL.
|
|
8
9
|
|
|
@@ -54,9 +55,15 @@ def example_task():
|
|
|
54
55
|
That's easy, right? Adding a job is just as easy:
|
|
55
56
|
|
|
56
57
|
```python
|
|
57
|
-
# Add a job to the queue
|
|
58
|
+
# Add a job to the queue with positional arguments
|
|
58
59
|
job = q.add_job(example_task, 5, "12")
|
|
59
60
|
print(f"Job added: {job.rid}")
|
|
61
|
+
|
|
62
|
+
# Add a job with keyword arguments (kwargs)
|
|
63
|
+
job = q.add_job(example_task, paramKeyed1="test", debug=True)
|
|
64
|
+
|
|
65
|
+
# Add a job with both positional and keyword arguments
|
|
66
|
+
job = q.add_job(example_task, 5, "12", paramKeyed1="test", debug=True)
|
|
60
67
|
```
|
|
61
68
|
|
|
62
69
|
In the initialisation of the queuer the existence of the necessary database tables is checked and if they don't exist they get created. The database is configured with these environment variables:
|
|
@@ -156,6 +163,72 @@ This method handles the registration of a task, making the worker able to pick u
|
|
|
156
163
|
|
|
157
164
|
---
|
|
158
165
|
|
|
166
|
+
## add_job
|
|
167
|
+
|
|
168
|
+
The `add_job` method adds a new job to the queue for execution. Jobs are units of work that will be processed by the queuer.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
def add_job(
|
|
172
|
+
self,
|
|
173
|
+
task: Union[Callable, str],
|
|
174
|
+
*parameters: Any,
|
|
175
|
+
**parameters_keyed: Any
|
|
176
|
+
) -> Job
|
|
177
|
+
|
|
178
|
+
def add_job_with_options(
|
|
179
|
+
self,
|
|
180
|
+
options: Optional[Options],
|
|
181
|
+
task: Union[Callable, str],
|
|
182
|
+
*parameters: Any,
|
|
183
|
+
**parameters_keyed: Any
|
|
184
|
+
) -> Job
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
- `task`: A `Callable` or `str` representing the task to execute. If a callable, it must be registered with `add_task` first.
|
|
188
|
+
- `options`: Optional `Options` for custom error handling or scheduling behavior. Only available in `add_job_with_options()`.
|
|
189
|
+
- `*parameters`: Positional arguments to pass to the task function.
|
|
190
|
+
- `**parameters_keyed`: Keyword arguments to pass to the task function (Python-specific feature).
|
|
191
|
+
|
|
192
|
+
**Examples:**
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
# Job with both positional and keyword arguments
|
|
196
|
+
job = queuer.add_job(my_task, "arg1", paramKeyed1="test", paramKeyed2=1)
|
|
197
|
+
|
|
198
|
+
# Job with custom options (requires add_job_with_options)
|
|
199
|
+
options = Options(on_error=OnError(max_retries=5))
|
|
200
|
+
job = queuer.add_job_with_options(options, my_task, "arg1", debug=True)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Note:** Keyword arguments (`**parameters_keyed`) are stored separately in the database and enable Python functions to be called with named parameters. This is useful for optional parameters, default values, and improved code clarity. Go jobs continue to use only positional parameters.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## add_jobs
|
|
208
|
+
|
|
209
|
+
The `add_jobs` method allows efficient batch insertion of multiple jobs at once.
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
def add_jobs(self, batch_jobs: List[BatchJob]) -> List[UUID]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- `batch_jobs`: A list of `BatchJob` instances to insert.
|
|
216
|
+
|
|
217
|
+
**Example:**
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from model.batch_job import BatchJob
|
|
221
|
+
|
|
222
|
+
batch = [
|
|
223
|
+
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
224
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
225
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
226
|
+
]
|
|
227
|
+
job_rids = queuer.add_jobs(batch)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
159
232
|
## add_next_interval_func
|
|
160
233
|
|
|
161
234
|
The `add_next_interval_func` method registers a custom function that determines the next execution time for scheduled jobs. This is useful for implementing complex scheduling logic beyond simple fixed intervals.
|
|
@@ -253,19 +326,20 @@ class Schedule:
|
|
|
253
326
|
### Job Management
|
|
254
327
|
|
|
255
328
|
```python
|
|
256
|
-
# Add a
|
|
257
|
-
job = queuer.add_job(my_task, param1, param2)
|
|
329
|
+
# Add a job with both positional and keyword arguments
|
|
330
|
+
job = queuer.add_job(my_task, param1, param2, paramKeyed1="test", paramKeyed2=1)
|
|
258
331
|
|
|
259
332
|
# Add a job with custom options
|
|
260
333
|
from model.options import Options, OnError
|
|
261
334
|
options = Options(on_error=OnError(max_retries=5, timeout=60.0))
|
|
262
|
-
job = queuer.add_job_with_options(options, my_task, param1)
|
|
335
|
+
job = queuer.add_job_with_options(options, my_task, param1, paramKeyed1="test")
|
|
263
336
|
|
|
264
337
|
# Add multiple jobs as a batch
|
|
265
338
|
from model.batch_job import BatchJob
|
|
266
339
|
batch = [
|
|
267
340
|
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
268
|
-
BatchJob(task=my_task, parameters=[2, "b"
|
|
341
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
342
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
269
343
|
]
|
|
270
344
|
queuer.add_jobs(batch)
|
|
271
345
|
|
|
@@ -292,6 +366,7 @@ worker_jobs = queuer.get_jobs_by_worker_rid(worker.rid)
|
|
|
292
366
|
|
|
293
367
|
# ⭐ Features
|
|
294
368
|
|
|
369
|
+
- **Keyword Arguments Support**: Python functions can use both positional arguments (`*args`) and keyword arguments (`**kwargs`), while maintaining compatibility with Go jobs that use only positional parameters.
|
|
295
370
|
- **Async/Await Support**: Full asyncio integration with threading fallbacks.
|
|
296
371
|
- **PostgreSQL NOTIFY/LISTEN**: Real-time job notifications without polling overhead.
|
|
297
372
|
- **Batch Job Processing**: Insert job batches efficiently using PostgreSQL's `COPY FROM` feature.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "queuerPy"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.17.0"
|
|
8
8
|
description = "A Python implementation of the queuer system - a job queuing and processing system with PostgreSQL backend"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -92,7 +92,7 @@ pythonVersion = "3.8"
|
|
|
92
92
|
pythonPlatform = "All"
|
|
93
93
|
|
|
94
94
|
[tool.mypy]
|
|
95
|
-
python_version = "0.
|
|
95
|
+
python_version = "0.17.0"
|
|
96
96
|
warn_return_any = true
|
|
97
97
|
warn_unused_configs = true
|
|
98
98
|
disallow_untyped_defs = true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queuerPy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: A Python implementation of the queuer system - a job queuing and processing system with PostgreSQL backend
|
|
5
5
|
Author-email: Simon Herrmann <siherrmann@users.noreply.github.com>
|
|
6
6
|
Maintainer-email: Simon Herrmann <siherrmann@users.noreply.github.com>
|
|
@@ -43,9 +43,10 @@ Dynamic: license-file
|
|
|
43
43
|
|
|
44
44
|
# queuerPy
|
|
45
45
|
|
|
46
|
+
[](https://pypi.org/project/queuerPy/)
|
|
46
47
|
[](https://www.python.org/)
|
|
47
|
-
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
48
48
|

|
|
49
|
+
[](https://github.com/siherrmann/queuer/blob/master/LICENSE)
|
|
49
50
|
|
|
50
51
|
Python port of the queuer package - a queueing system based on PostgreSQL.
|
|
51
52
|
|
|
@@ -97,9 +98,15 @@ def example_task():
|
|
|
97
98
|
That's easy, right? Adding a job is just as easy:
|
|
98
99
|
|
|
99
100
|
```python
|
|
100
|
-
# Add a job to the queue
|
|
101
|
+
# Add a job to the queue with positional arguments
|
|
101
102
|
job = q.add_job(example_task, 5, "12")
|
|
102
103
|
print(f"Job added: {job.rid}")
|
|
104
|
+
|
|
105
|
+
# Add a job with keyword arguments (kwargs)
|
|
106
|
+
job = q.add_job(example_task, paramKeyed1="test", debug=True)
|
|
107
|
+
|
|
108
|
+
# Add a job with both positional and keyword arguments
|
|
109
|
+
job = q.add_job(example_task, 5, "12", paramKeyed1="test", debug=True)
|
|
103
110
|
```
|
|
104
111
|
|
|
105
112
|
In the initialisation of the queuer the existence of the necessary database tables is checked and if they don't exist they get created. The database is configured with these environment variables:
|
|
@@ -199,6 +206,72 @@ This method handles the registration of a task, making the worker able to pick u
|
|
|
199
206
|
|
|
200
207
|
---
|
|
201
208
|
|
|
209
|
+
## add_job
|
|
210
|
+
|
|
211
|
+
The `add_job` method adds a new job to the queue for execution. Jobs are units of work that will be processed by the queuer.
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
def add_job(
|
|
215
|
+
self,
|
|
216
|
+
task: Union[Callable, str],
|
|
217
|
+
*parameters: Any,
|
|
218
|
+
**parameters_keyed: Any
|
|
219
|
+
) -> Job
|
|
220
|
+
|
|
221
|
+
def add_job_with_options(
|
|
222
|
+
self,
|
|
223
|
+
options: Optional[Options],
|
|
224
|
+
task: Union[Callable, str],
|
|
225
|
+
*parameters: Any,
|
|
226
|
+
**parameters_keyed: Any
|
|
227
|
+
) -> Job
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- `task`: A `Callable` or `str` representing the task to execute. If a callable, it must be registered with `add_task` first.
|
|
231
|
+
- `options`: Optional `Options` for custom error handling or scheduling behavior. Only available in `add_job_with_options()`.
|
|
232
|
+
- `*parameters`: Positional arguments to pass to the task function.
|
|
233
|
+
- `**parameters_keyed`: Keyword arguments to pass to the task function (Python-specific feature).
|
|
234
|
+
|
|
235
|
+
**Examples:**
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
# Job with both positional and keyword arguments
|
|
239
|
+
job = queuer.add_job(my_task, "arg1", paramKeyed1="test", paramKeyed2=1)
|
|
240
|
+
|
|
241
|
+
# Job with custom options (requires add_job_with_options)
|
|
242
|
+
options = Options(on_error=OnError(max_retries=5))
|
|
243
|
+
job = queuer.add_job_with_options(options, my_task, "arg1", debug=True)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Note:** Keyword arguments (`**parameters_keyed`) are stored separately in the database and enable Python functions to be called with named parameters. This is useful for optional parameters, default values, and improved code clarity. Go jobs continue to use only positional parameters.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## add_jobs
|
|
251
|
+
|
|
252
|
+
The `add_jobs` method allows efficient batch insertion of multiple jobs at once.
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
def add_jobs(self, batch_jobs: List[BatchJob]) -> List[UUID]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- `batch_jobs`: A list of `BatchJob` instances to insert.
|
|
259
|
+
|
|
260
|
+
**Example:**
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from model.batch_job import BatchJob
|
|
264
|
+
|
|
265
|
+
batch = [
|
|
266
|
+
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
267
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
268
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
269
|
+
]
|
|
270
|
+
job_rids = queuer.add_jobs(batch)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
202
275
|
## add_next_interval_func
|
|
203
276
|
|
|
204
277
|
The `add_next_interval_func` method registers a custom function that determines the next execution time for scheduled jobs. This is useful for implementing complex scheduling logic beyond simple fixed intervals.
|
|
@@ -296,19 +369,20 @@ class Schedule:
|
|
|
296
369
|
### Job Management
|
|
297
370
|
|
|
298
371
|
```python
|
|
299
|
-
# Add a
|
|
300
|
-
job = queuer.add_job(my_task, param1, param2)
|
|
372
|
+
# Add a job with both positional and keyword arguments
|
|
373
|
+
job = queuer.add_job(my_task, param1, param2, paramKeyed1="test", paramKeyed2=1)
|
|
301
374
|
|
|
302
375
|
# Add a job with custom options
|
|
303
376
|
from model.options import Options, OnError
|
|
304
377
|
options = Options(on_error=OnError(max_retries=5, timeout=60.0))
|
|
305
|
-
job = queuer.add_job_with_options(options, my_task, param1)
|
|
378
|
+
job = queuer.add_job_with_options(options, my_task, param1, paramKeyed1="test")
|
|
306
379
|
|
|
307
380
|
# Add multiple jobs as a batch
|
|
308
381
|
from model.batch_job import BatchJob
|
|
309
382
|
batch = [
|
|
310
383
|
BatchJob(task=my_task, parameters=[1, "a"]),
|
|
311
|
-
BatchJob(task=my_task, parameters=[2, "b"
|
|
384
|
+
BatchJob(task=my_task, parameters=[2], parameters_keyed={"name": "b"}),
|
|
385
|
+
BatchJob(task=my_task, parameters_keyed={"id": 3, "name": "c"})
|
|
312
386
|
]
|
|
313
387
|
queuer.add_jobs(batch)
|
|
314
388
|
|
|
@@ -335,6 +409,7 @@ worker_jobs = queuer.get_jobs_by_worker_rid(worker.rid)
|
|
|
335
409
|
|
|
336
410
|
# ⭐ Features
|
|
337
411
|
|
|
412
|
+
- **Keyword Arguments Support**: Python functions can use both positional arguments (`*args`) and keyword arguments (`**kwargs`), while maintaining compatibility with Go jobs that use only positional parameters.
|
|
338
413
|
- **Async/Await Support**: Full asyncio integration with threading fallbacks.
|
|
339
414
|
- **PostgreSQL NOTIFY/LISTEN**: Real-time job notifications without polling overhead.
|
|
340
415
|
- **Batch Job Processing**: Insert job batches efficiently using PostgreSQL's `COPY FROM` feature.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|