|
14 | 14 | from settings_library.redis import RedisDatabase, RedisSettings |
15 | 15 | from tenacity import ( |
16 | 16 | AsyncRetrying, |
17 | | - TryAgain, |
18 | | - retry_if_exception_type, |
| 17 | + retry_unless_exception_type, |
19 | 18 | stop_after_delay, |
20 | 19 | wait_exponential, |
21 | 20 | ) |
@@ -458,17 +457,16 @@ async def remove_task( |
458 | 457 |
|
459 | 458 | # wait for task to be removed since it might not have been running |
460 | 459 | # in this process |
461 | | - async for attempt in AsyncRetrying( |
462 | | - wait=wait_exponential(max=1), |
463 | | - stop=stop_after_delay(_TASK_REMOVAL_MAX_WAIT), |
464 | | - retry=retry_if_exception_type(TryAgain), |
465 | | - ): |
466 | | - with attempt: # noqa: SIM117 |
467 | | - with suppress(TaskNotFoundError): |
| 460 | + with suppress(TaskNotFoundError): |
| 461 | + async for attempt in AsyncRetrying( |
| 462 | + wait=wait_exponential(max=1), |
| 463 | + stop=stop_after_delay(_TASK_REMOVAL_MAX_WAIT), |
| 464 | + retry=retry_unless_exception_type(TaskNotFoundError), |
| 465 | + ): |
| 466 | + with attempt: |
468 | 467 | await self._get_tracked_task( |
469 | 468 | tracked_task.task_id, tracked_task.task_context |
470 | 469 | ) |
471 | | - raise TryAgain |
472 | 470 |
|
473 | 471 | def _get_task_id(self, task_name: str, *, is_unique: bool) -> TaskId: |
474 | 472 | suffix = "unique" if is_unique else f"{uuid4()}" |
|
0 commit comments