Commit df3a560
UN-3211 [FEAT] HTTP session lifecycle management for workers API clients (#1782)
* UN-3211 [FEAT] HTTP session lifecycle management for workers API clients
- Add _owns_session flag to prevent singleton shared session from being
closed by individual clients
- Wire API_CLIENT_POOL_SIZE into HTTPAdapter connection pools
- Add idempotent close() and __del__ destructor to BaseAPIClient
- Add try/finally cleanup in api-deployment and callback tasks
- Add on_worker_process_shutdown hook and early-return guard in postrun
- Add 25 unit tests for session lifecycle behavior
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* UN-3211 [FIX] Address CodeRabbit review: log reset failures, thread-safe counter
- Log warning instead of silently swallowing exceptions in reset_singleton()
- Add threading.Lock around task counter increment for thread safety with
threads/gevent/eventlet pools
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* UN-3211 [FIX] Address CodeRabbit review round 2: optimize lock scope, document thread-safety
- Move WorkerConfig() instantiation outside lock in increment_task_counter()
- Remove redundant _task_counter=0 (already done inside reset_singleton)
- Document thread-safety caveat in reset_singleton() docstring
- Log close failures in task cleanup instead of silently swallowing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* UN-3211 [FIX] Address CodeRabbit review round 3: test real on_task_postrun handler
Tests now call the real worker.on_task_postrun() signal handler instead of
simulating the guard logic inline, catching divergence if the handler's
guard, try/except, or import path changes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* UN-3211 [FIX] Optimize singleton reset with cached threshold and improve close() logging
Cache the singleton_reset_task_threshold to avoid re-importing WorkerConfig on
every task increment. Promote api_client.close() failure logs from debug to
warning for better production visibility. Update tests to reset cached threshold.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* UN-3211 [FIX] Improve API execution error handling and clean up worker imports
Refactor api-deployment tasks to handle setup failures early with proper
cleanup, move shared imports to module level in worker.py, and fix type
annotations in client_factory.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com>
Co-authored-by: Kirtiman Mishra <110175055+kirtimanmishrazipstack@users.noreply.github.com>1 parent dcb226b commit df3a560
12 files changed
Lines changed: 1063 additions & 324 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | | - | |
173 | | - | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
177 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
178 | 195 | | |
179 | 196 | | |
180 | 197 | | |
| |||
216 | 233 | | |
217 | 234 | | |
218 | 235 | | |
219 | | - | |
| 236 | + | |
220 | 237 | | |
221 | 238 | | |
222 | 239 | | |
223 | 240 | | |
224 | | - | |
| 241 | + | |
225 | 242 | | |
226 | 243 | | |
227 | 244 | | |
| |||
233 | 250 | | |
234 | 251 | | |
235 | 252 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | 253 | | |
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
249 | 257 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
255 | 261 | | |
256 | 262 | | |
257 | 263 | | |
| |||
261 | 267 | | |
262 | 268 | | |
263 | 269 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | 270 | | |
278 | 271 | | |
279 | 272 | | |
280 | 273 | | |
281 | 274 | | |
282 | 275 | | |
283 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| |||
0 commit comments