Commit 40f4c4a
committed
Fix Celery SoftTimeLimitExceeded exception handling
When using the OpenAI client in Celery tasks with soft time limits, the client's
broad exception handling was catching SoftTimeLimitExceeded and treating it as
a retryable connection error. This prevented Celery tasks from properly handling
timeouts and running cleanup logic.
This change adds a check to identify termination signals (like Celery's
SoftTimeLimitExceeded or asyncio's CancelledError) and re-raises them immediately
without retry. This allows task executors to properly handle these signals.
Changes:
- Added _should_not_retry() helper to identify termination signals
- Modified sync and async exception handlers to check before retrying
- Added test to verify termination signals are not retried
Fixes #27371 parent 4e88565 commit 40f4c4a
2 files changed
+69
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
91 | 121 | | |
92 | 122 | | |
93 | 123 | | |
| |||
1001 | 1031 | | |
1002 | 1032 | | |
1003 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1004 | 1038 | | |
1005 | 1039 | | |
1006 | 1040 | | |
| |||
1548 | 1582 | | |
1549 | 1583 | | |
1550 | 1584 | | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1551 | 1589 | | |
1552 | 1590 | | |
1553 | 1591 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
868 | 899 | | |
869 | 900 | | |
870 | 901 | | |
| |||
0 commit comments