Commit c1fa860
authored
feat(python): add max_concurrency and concurrency_timeout for UDF protection (#20)
* feat(python): add max_concurrency and concurrency_timeout for UDF protection
- Add max_concurrency parameter to limit concurrent requests per function
- Add concurrency_timeout parameter to control wait behavior
- Default behavior: wait indefinitely when limit is reached
- With timeout: reject with ConcurrencyLimitExceeded after timeout expires
- Add Prometheus counter for rejected requests
- Add comprehensive tests for concurrency limiting
- Update README with documentation
* fix: only release semaphore if successfully acquired
Fix bug where semaphore.release() was called in finally block even when
acquire() timed out and returned False. This would incorrectly increment
the semaphore counter, allowing more concurrent requests than configured.
* fix: only release semaphore if successfully acquired
Fix bug where semaphore.release() was called in finally block even when
acquire() timed out and returned False. This would incorrectly increment
the semaphore counter, allowing more concurrent requests than configured.
Also remove Chinese comments from comprehensive_server.py.
* fix: remove unused imports in test_max_concurrency.py
* style: format code with ruff1 parent 7d7bc29 commit c1fa860
File tree
7 files changed
+497
-61
lines changed- python
- databend_udf
- tests
- servers
7 files changed
+497
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
155 | | - | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
159 | 207 | | |
160 | 208 | | |
161 | 209 | | |
| |||
170 | 218 | | |
171 | 219 | | |
172 | 220 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
181 | 231 | | |
182 | 232 | | |
183 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
0 commit comments