streamlit-octostar-utils 0.1.7a8__py3-none-any.whl → 0.1.7a9__py3-none-any.whl
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.
- streamlit_octostar_utils/api_crafter/celery.py +25 -28
- streamlit_octostar_utils/api_crafter/fastapi.py +30 -19
- {streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/METADATA +1 -1
- {streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/RECORD +6 -6
- {streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/LICENSE +0 -0
- {streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/WHEEL +0 -0
@@ -493,18 +493,9 @@ class CeleryExecutor(object):
|
|
493
493
|
task_id,
|
494
494
|
)
|
495
495
|
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
)
|
500
|
-
|
501
|
-
except CeleryExecutor.QueueFullException as e:
|
502
|
-
if os.path.isfile(os.path.join(self.in_folder, task_id)):
|
503
|
-
with RedisFileLock(self.redis_client, os.path.join(self.in_folder, task_id)):
|
504
|
-
os.remove(os.path.join(self.in_folder, task_id))
|
505
|
-
|
506
|
-
logger.warning(f"Queue full exception: {str(e)}")
|
507
|
-
return None
|
496
|
+
await asyncio.get_running_loop().run_in_executor(
|
497
|
+
self.set_thread_pool, _send_task, task_fn, task_id, options
|
498
|
+
)
|
508
499
|
|
509
500
|
except asyncio.CancelledError:
|
510
501
|
logger.info(f"Cancelling task {task_id} due to disconnect!")
|
@@ -694,20 +685,26 @@ class CeleryErrorRoute(DefaultErrorRoute):
|
|
694
685
|
DEFAULT_SILENCED_EXCEPTIONS = {CeleryExecutor.QueueFullException: lambda exc: True}
|
695
686
|
|
696
687
|
def add_default_exceptions_handler(
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
log_filter=None,
|
688
|
+
fs_app,
|
689
|
+
debug=False,
|
690
|
+
excs_to_status_codes=None,
|
691
|
+
silenced_excs=None,
|
702
692
|
):
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
693
|
+
extra_status = {CeleryExecutor.QueueFullException: lambda exc: 429}
|
694
|
+
extra_silence = {CeleryExecutor.QueueFullException: lambda exc: True}
|
695
|
+
|
696
|
+
status_codes = {
|
697
|
+
**DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS,
|
698
|
+
**(excs_to_status_codes or {}),
|
699
|
+
**extra_status,
|
700
|
+
}
|
701
|
+
|
702
|
+
silenced = {
|
703
|
+
**DefaultErrorRoute.DEFAULT_SILENCED_EXCEPTIONS,
|
704
|
+
**(silenced_excs or {}),
|
705
|
+
**extra_silence,
|
706
|
+
}
|
707
|
+
|
708
|
+
super(CeleryErrorRoute, CeleryErrorRoute).add_default_exceptions_handler(
|
709
|
+
fs_app, debug, status_codes, silenced
|
710
|
+
)
|
@@ -241,20 +241,30 @@ class CommonModels(object):
|
|
241
241
|
headers["Content-Disposition"] += f' filename="{filename}"'
|
242
242
|
return StreamingResponse(zip_buffer, media_type="application/zip", headers=headers)
|
243
243
|
|
244
|
+
|
244
245
|
class ErrorLogFilter(logging.Filter):
|
245
|
-
def __init__(self, silenced_excs: dict):
|
246
|
+
def __init__(self, silenced_excs: dict[type, callable]):
|
246
247
|
super().__init__()
|
247
248
|
self.silenced_excs = silenced_excs
|
248
|
-
|
249
|
-
def
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
249
|
+
|
250
|
+
def _silenced(self, exc_value) -> bool:
|
251
|
+
for etype, cond in self.silenced_excs.items():
|
252
|
+
if isinstance(exc_value, etype) and cond(exc_value):
|
253
|
+
return True
|
254
|
+
return False
|
255
|
+
|
256
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
257
|
+
if record.exc_info:
|
258
|
+
exc_type, exc_value, _ = record.exc_info
|
259
|
+
if self._silenced(exc_value):
|
260
|
+
return False
|
261
|
+
|
262
|
+
msg = record.getMessage()
|
263
|
+
for etype in self.silenced_excs:
|
264
|
+
if etype.__name__ in msg:
|
265
|
+
if self.silenced_excs[etype](None):
|
266
|
+
return False
|
267
|
+
|
258
268
|
return True
|
259
269
|
|
260
270
|
|
@@ -334,10 +344,10 @@ class DefaultErrorRoute:
|
|
334
344
|
return DefaultErrorRoute.format_error(exc, body, debug, excs_to_status_codes)
|
335
345
|
|
336
346
|
def add_default_exceptions_handler(
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
347
|
+
fs_app,
|
348
|
+
debug=False,
|
349
|
+
excs_to_status_codes=None,
|
350
|
+
silenced_excs=None,
|
341
351
|
):
|
342
352
|
if excs_to_status_codes is None:
|
343
353
|
excs_to_status_codes = DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS
|
@@ -351,11 +361,12 @@ class DefaultErrorRoute:
|
|
351
361
|
fs_app.add_exception_handler(RequestValidationError, _async_handle_error)
|
352
362
|
fs_app.add_exception_handler(StarletteHTTPException, _async_handle_error)
|
353
363
|
fs_app.add_exception_handler(Exception, _async_handle_error)
|
354
|
-
|
364
|
+
|
355
365
|
log_filter = ErrorLogFilter(silenced_excs)
|
356
|
-
|
357
|
-
|
358
|
-
|
366
|
+
for name in ("uvicorn.error", "uvicorn.access", "fastapi", "uvicorn"):
|
367
|
+
logging.getLogger(name).addFilter(log_filter)
|
368
|
+
|
369
|
+
logging.getLogger().addFilter(log_filter)
|
359
370
|
|
360
371
|
class RequestCancelledMiddleware:
|
361
372
|
def __init__(self, app):
|
{streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/RECORD
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
streamlit_octostar_utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
2
2
|
streamlit_octostar_utils/api_crafter/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
3
|
-
streamlit_octostar_utils/api_crafter/celery.py,sha256=
|
4
|
-
streamlit_octostar_utils/api_crafter/fastapi.py,sha256=
|
3
|
+
streamlit_octostar_utils/api_crafter/celery.py,sha256=bQq8P95j0XDWqx6Hdnm96PJL8kcp9ZcSKjveZUCQTVk,29874
|
4
|
+
streamlit_octostar_utils/api_crafter/fastapi.py,sha256=vuy8cMY8as9GZc5cjBjZJXnudrqjYlPu1QGEyIKYKXw,14365
|
5
5
|
streamlit_octostar_utils/api_crafter/nifi.py,sha256=fQ5k9eZl2oSQZ2BexZYwKUiO05-FryUi7wnCd_56P9Y,44375
|
6
6
|
streamlit_octostar_utils/api_crafter/parser/__init__.py,sha256=YeYWF6sdQiCFV_RKNW2t9Vs6KJExE2pbXxWTe_DOayY,107
|
7
7
|
streamlit_octostar_utils/api_crafter/parser/combine_fields.py,sha256=ddc44xkajw8MU0peAX_263DL7rPXbTKbHUjpOhRgvyU,8790
|
@@ -37,7 +37,7 @@ streamlit_octostar_utils/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzp
|
|
37
37
|
streamlit_octostar_utils/threading/async_task_manager.py,sha256=q7N6YZwUvIYMzkSHmsJNheNVCv93c03H6Hyg9uH8pvk,4747
|
38
38
|
streamlit_octostar_utils/threading/session_callback_manager.py,sha256=LvZVP4g6tvKtYmI13f2j1sX_7hm61Groqp5xJine9_k,3973
|
39
39
|
streamlit_octostar_utils/threading/session_state_hot_swapper.py,sha256=6eeCQI6A42hp4DmW2NQw2rbeR-k9N8DhfBKQdN_fbLU,811
|
40
|
-
streamlit_octostar_utils-0.1.
|
41
|
-
streamlit_octostar_utils-0.1.
|
42
|
-
streamlit_octostar_utils-0.1.
|
43
|
-
streamlit_octostar_utils-0.1.
|
40
|
+
streamlit_octostar_utils-0.1.7a9.dist-info/LICENSE,sha256=dkwVPyV03fPHHtERnF6RnvRXcll__tud9gWca1RcgnQ,1073
|
41
|
+
streamlit_octostar_utils-0.1.7a9.dist-info/METADATA,sha256=VhXEOXyzVQhwg8qgd8XdBep95_fyXTk-4Lq2JhdpkzU,2267
|
42
|
+
streamlit_octostar_utils-0.1.7a9.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
43
|
+
streamlit_octostar_utils-0.1.7a9.dist-info/RECORD,,
|
{streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/LICENSE
RENAMED
File without changes
|
{streamlit_octostar_utils-0.1.7a8.dist-info → streamlit_octostar_utils-0.1.7a9.dist-info}/WHEEL
RENAMED
File without changes
|