queuerPy 0.18.0__tar.gz → 0.19.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.18.0/queuerPy.egg-info → queuerpy-0.19.0}/PKG-INFO +55 -12
- {queuerpy-0.18.0 → queuerpy-0.19.0}/README.md +54 -11
- {queuerpy-0.18.0 → queuerpy-0.19.0}/_version.py +1 -1
- {queuerpy-0.18.0 → queuerpy-0.19.0}/pyproject.toml +2 -2
- {queuerpy-0.18.0 → queuerpy-0.19.0/queuerPy.egg-info}/PKG-INFO +55 -12
- {queuerpy-0.18.0 → queuerpy-0.19.0}/LICENSE +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/MANIFEST.in +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/__init__.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/__init__.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/broadcaster.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/listener.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/retryer.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/runner.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/scheduler.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/core/ticker.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/database/__init__.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/database/db_job.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/database/db_listener.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/database/db_master.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/database/db_worker.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/__init__.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/database.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/error.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/logging.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/sql.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/helper/task.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/__init__.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/batch_job.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/connection.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/job.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/master.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/options.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/options_on_error.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/task.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/model/worker.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/py.typed +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuerPy.egg-info/SOURCES.txt +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuerPy.egg-info/dependency_links.txt +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuerPy.egg-info/requires.txt +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuerPy.egg-info/top_level.txt +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_global.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_job.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_listener.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_master.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_next_interval.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_task.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/queuer_worker.py +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/setup.cfg +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/sql/job.sql +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/sql/master.sql +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.0}/sql/notify.sql +0 -0
- {queuerpy-0.18.0 → queuerpy-0.19.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.19.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>
|
|
@@ -58,9 +58,7 @@ The job table contains only queued, scheduled and running tasks. The ended jobs
|
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## PyPI Installation (Recommended)
|
|
61
|
+
## 🛠️ Installation
|
|
64
62
|
|
|
65
63
|
```bash
|
|
66
64
|
pip install queuerPy
|
|
@@ -134,10 +132,10 @@ You can find a full example in the example folder.
|
|
|
134
132
|
def new_queuer(name: str, max_concurrency: int, *options: OnError) -> Queuer
|
|
135
133
|
|
|
136
134
|
def new_queuer_with_db(
|
|
137
|
-
name: str,
|
|
138
|
-
max_concurrency: int,
|
|
139
|
-
encryption_key: str,
|
|
140
|
-
db_config: DatabaseConfiguration,
|
|
135
|
+
name: str,
|
|
136
|
+
max_concurrency: int,
|
|
137
|
+
encryption_key: str,
|
|
138
|
+
db_config: DatabaseConfiguration,
|
|
141
139
|
*options: OnError
|
|
142
140
|
) -> Queuer
|
|
143
141
|
```
|
|
@@ -149,6 +147,7 @@ def new_queuer_with_db(
|
|
|
149
147
|
- `options`: Optional `OnError` configurations to apply to the worker.
|
|
150
148
|
|
|
151
149
|
This function performs the following setup:
|
|
150
|
+
|
|
152
151
|
- Initializes a logger.
|
|
153
152
|
- Sets up the database connection using the provided `db_config` or environment variables.
|
|
154
153
|
- Creates `JobDBHandler`, `WorkerDBHandler` instances for database interactions.
|
|
@@ -167,6 +166,7 @@ def start(self) -> None
|
|
|
167
166
|
```
|
|
168
167
|
|
|
169
168
|
Upon calling `start`:
|
|
169
|
+
|
|
170
170
|
- It performs a basic check to ensure internal listeners are initialized.
|
|
171
171
|
- Database listeners are created to listen to job events (inserts, updates, deletes) via PostgreSQL NOTIFY/LISTEN.
|
|
172
172
|
- It starts a poller to periodically poll the database for new jobs to process.
|
|
@@ -185,7 +185,50 @@ The `stop` method gracefully shuts down the Queuer instance, releasing resources
|
|
|
185
185
|
def stop(self) -> None
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
The `stop` method cancels all jobs, closes database listeners, and cleans up resources.
|
|
188
|
+
The `stop` method cancels all jobs, closes database listeners, and cleans up resources. **Note:** This method can only be used to stop the current worker instance that the code is running in. To stop other workers, use `stop_worker` or `stop_worker_gracefully`.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## stop_worker
|
|
193
|
+
|
|
194
|
+
The `stop_worker` method immediately stops a worker by setting its status to `STOPPED`. This will cancel all running jobs on that worker.
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
def stop_worker(self, worker_rid: UUID) -> None
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
- `worker_rid`: The `UUID` identifying the worker to stop.
|
|
201
|
+
|
|
202
|
+
When a worker is stopped:
|
|
203
|
+
|
|
204
|
+
- The worker status is immediately set to `STOPPED` in the database
|
|
205
|
+
- The heartbeat ticker detects the `STOPPED` status and calls `stop()` on that worker
|
|
206
|
+
- All running jobs on that worker are cancelled immediately
|
|
207
|
+
- The worker will no longer accept new jobs
|
|
208
|
+
|
|
209
|
+
This method is useful for immediately shutting down a worker, for example in emergency situations or when you need to take a worker offline quickly.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## stop_worker_gracefully
|
|
214
|
+
|
|
215
|
+
The `stop_worker_gracefully` method gracefully stops a worker by setting its status to `STOPPING`. This allows currently running jobs to complete before the worker shuts down.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
def stop_worker_gracefully(self, worker_rid: UUID) -> None
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- `worker_rid`: The `UUID` identifying the worker to stop gracefully.
|
|
222
|
+
|
|
223
|
+
When a worker is stopped gracefully:
|
|
224
|
+
|
|
225
|
+
- The worker status is set to `STOPPING` in the database
|
|
226
|
+
- The heartbeat ticker detects the `STOPPING` status and sets `max_concurrency` to `0`
|
|
227
|
+
- Currently running jobs are allowed to complete normally
|
|
228
|
+
- No new jobs will be accepted by this worker
|
|
229
|
+
- Once all running jobs have finished, the worker status is automatically set to `STOPPED` and the worker shuts down
|
|
230
|
+
|
|
231
|
+
This method is ideal for maintenance scenarios where you want to ensure all in-progress work completes before shutting down the worker.
|
|
189
232
|
|
|
190
233
|
---
|
|
191
234
|
|
|
@@ -212,8 +255,8 @@ The `add_job` method adds a new job to the queue for execution. Jobs are units o
|
|
|
212
255
|
|
|
213
256
|
```python
|
|
214
257
|
def add_job(
|
|
215
|
-
self,
|
|
216
|
-
task: Union[Callable, str],
|
|
258
|
+
self,
|
|
259
|
+
task: Union[Callable, str],
|
|
217
260
|
*parameters: Any,
|
|
218
261
|
**parameters_keyed: Any
|
|
219
262
|
) -> Job
|
|
@@ -322,7 +365,7 @@ class RetryBackoff(str, Enum):
|
|
|
322
365
|
|
|
323
366
|
- `RETRY_BACKOFF_NONE`: No backoff. The retry_delay remains constant for all retries.
|
|
324
367
|
- `RETRY_BACKOFF_LINEAR`: The retry delay increases linearly with each attempt (e.g., delay, 2*delay, 3*delay).
|
|
325
|
-
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2
|
|
368
|
+
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2\*2).
|
|
326
369
|
|
|
327
370
|
---
|
|
328
371
|
|
|
@@ -15,9 +15,7 @@ The job table contains only queued, scheduled and running tasks. The ended jobs
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## PyPI Installation (Recommended)
|
|
18
|
+
## 🛠️ Installation
|
|
21
19
|
|
|
22
20
|
```bash
|
|
23
21
|
pip install queuerPy
|
|
@@ -91,10 +89,10 @@ You can find a full example in the example folder.
|
|
|
91
89
|
def new_queuer(name: str, max_concurrency: int, *options: OnError) -> Queuer
|
|
92
90
|
|
|
93
91
|
def new_queuer_with_db(
|
|
94
|
-
name: str,
|
|
95
|
-
max_concurrency: int,
|
|
96
|
-
encryption_key: str,
|
|
97
|
-
db_config: DatabaseConfiguration,
|
|
92
|
+
name: str,
|
|
93
|
+
max_concurrency: int,
|
|
94
|
+
encryption_key: str,
|
|
95
|
+
db_config: DatabaseConfiguration,
|
|
98
96
|
*options: OnError
|
|
99
97
|
) -> Queuer
|
|
100
98
|
```
|
|
@@ -106,6 +104,7 @@ def new_queuer_with_db(
|
|
|
106
104
|
- `options`: Optional `OnError` configurations to apply to the worker.
|
|
107
105
|
|
|
108
106
|
This function performs the following setup:
|
|
107
|
+
|
|
109
108
|
- Initializes a logger.
|
|
110
109
|
- Sets up the database connection using the provided `db_config` or environment variables.
|
|
111
110
|
- Creates `JobDBHandler`, `WorkerDBHandler` instances for database interactions.
|
|
@@ -124,6 +123,7 @@ def start(self) -> None
|
|
|
124
123
|
```
|
|
125
124
|
|
|
126
125
|
Upon calling `start`:
|
|
126
|
+
|
|
127
127
|
- It performs a basic check to ensure internal listeners are initialized.
|
|
128
128
|
- Database listeners are created to listen to job events (inserts, updates, deletes) via PostgreSQL NOTIFY/LISTEN.
|
|
129
129
|
- It starts a poller to periodically poll the database for new jobs to process.
|
|
@@ -142,7 +142,50 @@ The `stop` method gracefully shuts down the Queuer instance, releasing resources
|
|
|
142
142
|
def stop(self) -> None
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
The `stop` method cancels all jobs, closes database listeners, and cleans up resources.
|
|
145
|
+
The `stop` method cancels all jobs, closes database listeners, and cleans up resources. **Note:** This method can only be used to stop the current worker instance that the code is running in. To stop other workers, use `stop_worker` or `stop_worker_gracefully`.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## stop_worker
|
|
150
|
+
|
|
151
|
+
The `stop_worker` method immediately stops a worker by setting its status to `STOPPED`. This will cancel all running jobs on that worker.
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
def stop_worker(self, worker_rid: UUID) -> None
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
- `worker_rid`: The `UUID` identifying the worker to stop.
|
|
158
|
+
|
|
159
|
+
When a worker is stopped:
|
|
160
|
+
|
|
161
|
+
- The worker status is immediately set to `STOPPED` in the database
|
|
162
|
+
- The heartbeat ticker detects the `STOPPED` status and calls `stop()` on that worker
|
|
163
|
+
- All running jobs on that worker are cancelled immediately
|
|
164
|
+
- The worker will no longer accept new jobs
|
|
165
|
+
|
|
166
|
+
This method is useful for immediately shutting down a worker, for example in emergency situations or when you need to take a worker offline quickly.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## stop_worker_gracefully
|
|
171
|
+
|
|
172
|
+
The `stop_worker_gracefully` method gracefully stops a worker by setting its status to `STOPPING`. This allows currently running jobs to complete before the worker shuts down.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
def stop_worker_gracefully(self, worker_rid: UUID) -> None
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- `worker_rid`: The `UUID` identifying the worker to stop gracefully.
|
|
179
|
+
|
|
180
|
+
When a worker is stopped gracefully:
|
|
181
|
+
|
|
182
|
+
- The worker status is set to `STOPPING` in the database
|
|
183
|
+
- The heartbeat ticker detects the `STOPPING` status and sets `max_concurrency` to `0`
|
|
184
|
+
- Currently running jobs are allowed to complete normally
|
|
185
|
+
- No new jobs will be accepted by this worker
|
|
186
|
+
- Once all running jobs have finished, the worker status is automatically set to `STOPPED` and the worker shuts down
|
|
187
|
+
|
|
188
|
+
This method is ideal for maintenance scenarios where you want to ensure all in-progress work completes before shutting down the worker.
|
|
146
189
|
|
|
147
190
|
---
|
|
148
191
|
|
|
@@ -169,8 +212,8 @@ The `add_job` method adds a new job to the queue for execution. Jobs are units o
|
|
|
169
212
|
|
|
170
213
|
```python
|
|
171
214
|
def add_job(
|
|
172
|
-
self,
|
|
173
|
-
task: Union[Callable, str],
|
|
215
|
+
self,
|
|
216
|
+
task: Union[Callable, str],
|
|
174
217
|
*parameters: Any,
|
|
175
218
|
**parameters_keyed: Any
|
|
176
219
|
) -> Job
|
|
@@ -279,7 +322,7 @@ class RetryBackoff(str, Enum):
|
|
|
279
322
|
|
|
280
323
|
- `RETRY_BACKOFF_NONE`: No backoff. The retry_delay remains constant for all retries.
|
|
281
324
|
- `RETRY_BACKOFF_LINEAR`: The retry delay increases linearly with each attempt (e.g., delay, 2*delay, 3*delay).
|
|
282
|
-
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2
|
|
325
|
+
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2\*2).
|
|
283
326
|
|
|
284
327
|
---
|
|
285
328
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "queuerPy"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.19.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.19.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.19.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>
|
|
@@ -58,9 +58,7 @@ The job table contains only queued, scheduled and running tasks. The ended jobs
|
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## PyPI Installation (Recommended)
|
|
61
|
+
## 🛠️ Installation
|
|
64
62
|
|
|
65
63
|
```bash
|
|
66
64
|
pip install queuerPy
|
|
@@ -134,10 +132,10 @@ You can find a full example in the example folder.
|
|
|
134
132
|
def new_queuer(name: str, max_concurrency: int, *options: OnError) -> Queuer
|
|
135
133
|
|
|
136
134
|
def new_queuer_with_db(
|
|
137
|
-
name: str,
|
|
138
|
-
max_concurrency: int,
|
|
139
|
-
encryption_key: str,
|
|
140
|
-
db_config: DatabaseConfiguration,
|
|
135
|
+
name: str,
|
|
136
|
+
max_concurrency: int,
|
|
137
|
+
encryption_key: str,
|
|
138
|
+
db_config: DatabaseConfiguration,
|
|
141
139
|
*options: OnError
|
|
142
140
|
) -> Queuer
|
|
143
141
|
```
|
|
@@ -149,6 +147,7 @@ def new_queuer_with_db(
|
|
|
149
147
|
- `options`: Optional `OnError` configurations to apply to the worker.
|
|
150
148
|
|
|
151
149
|
This function performs the following setup:
|
|
150
|
+
|
|
152
151
|
- Initializes a logger.
|
|
153
152
|
- Sets up the database connection using the provided `db_config` or environment variables.
|
|
154
153
|
- Creates `JobDBHandler`, `WorkerDBHandler` instances for database interactions.
|
|
@@ -167,6 +166,7 @@ def start(self) -> None
|
|
|
167
166
|
```
|
|
168
167
|
|
|
169
168
|
Upon calling `start`:
|
|
169
|
+
|
|
170
170
|
- It performs a basic check to ensure internal listeners are initialized.
|
|
171
171
|
- Database listeners are created to listen to job events (inserts, updates, deletes) via PostgreSQL NOTIFY/LISTEN.
|
|
172
172
|
- It starts a poller to periodically poll the database for new jobs to process.
|
|
@@ -185,7 +185,50 @@ The `stop` method gracefully shuts down the Queuer instance, releasing resources
|
|
|
185
185
|
def stop(self) -> None
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
The `stop` method cancels all jobs, closes database listeners, and cleans up resources.
|
|
188
|
+
The `stop` method cancels all jobs, closes database listeners, and cleans up resources. **Note:** This method can only be used to stop the current worker instance that the code is running in. To stop other workers, use `stop_worker` or `stop_worker_gracefully`.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## stop_worker
|
|
193
|
+
|
|
194
|
+
The `stop_worker` method immediately stops a worker by setting its status to `STOPPED`. This will cancel all running jobs on that worker.
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
def stop_worker(self, worker_rid: UUID) -> None
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
- `worker_rid`: The `UUID` identifying the worker to stop.
|
|
201
|
+
|
|
202
|
+
When a worker is stopped:
|
|
203
|
+
|
|
204
|
+
- The worker status is immediately set to `STOPPED` in the database
|
|
205
|
+
- The heartbeat ticker detects the `STOPPED` status and calls `stop()` on that worker
|
|
206
|
+
- All running jobs on that worker are cancelled immediately
|
|
207
|
+
- The worker will no longer accept new jobs
|
|
208
|
+
|
|
209
|
+
This method is useful for immediately shutting down a worker, for example in emergency situations or when you need to take a worker offline quickly.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## stop_worker_gracefully
|
|
214
|
+
|
|
215
|
+
The `stop_worker_gracefully` method gracefully stops a worker by setting its status to `STOPPING`. This allows currently running jobs to complete before the worker shuts down.
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
def stop_worker_gracefully(self, worker_rid: UUID) -> None
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- `worker_rid`: The `UUID` identifying the worker to stop gracefully.
|
|
222
|
+
|
|
223
|
+
When a worker is stopped gracefully:
|
|
224
|
+
|
|
225
|
+
- The worker status is set to `STOPPING` in the database
|
|
226
|
+
- The heartbeat ticker detects the `STOPPING` status and sets `max_concurrency` to `0`
|
|
227
|
+
- Currently running jobs are allowed to complete normally
|
|
228
|
+
- No new jobs will be accepted by this worker
|
|
229
|
+
- Once all running jobs have finished, the worker status is automatically set to `STOPPED` and the worker shuts down
|
|
230
|
+
|
|
231
|
+
This method is ideal for maintenance scenarios where you want to ensure all in-progress work completes before shutting down the worker.
|
|
189
232
|
|
|
190
233
|
---
|
|
191
234
|
|
|
@@ -212,8 +255,8 @@ The `add_job` method adds a new job to the queue for execution. Jobs are units o
|
|
|
212
255
|
|
|
213
256
|
```python
|
|
214
257
|
def add_job(
|
|
215
|
-
self,
|
|
216
|
-
task: Union[Callable, str],
|
|
258
|
+
self,
|
|
259
|
+
task: Union[Callable, str],
|
|
217
260
|
*parameters: Any,
|
|
218
261
|
**parameters_keyed: Any
|
|
219
262
|
) -> Job
|
|
@@ -322,7 +365,7 @@ class RetryBackoff(str, Enum):
|
|
|
322
365
|
|
|
323
366
|
- `RETRY_BACKOFF_NONE`: No backoff. The retry_delay remains constant for all retries.
|
|
324
367
|
- `RETRY_BACKOFF_LINEAR`: The retry delay increases linearly with each attempt (e.g., delay, 2*delay, 3*delay).
|
|
325
|
-
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2
|
|
368
|
+
- `RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2\*2).
|
|
326
369
|
|
|
327
370
|
---
|
|
328
371
|
|
|
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
|
|
File without changes
|