File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
packages/celery-library/src/celery_library Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 11import base64
22import pickle
3+ from functools import wraps
4+ from inspect import isasyncgenfunction
35
46from celery .exceptions import CeleryError # type: ignore[import-untyped]
57from common_library .errors_classes import OsparcErrorMixin
@@ -42,6 +44,19 @@ class InternalError(OsparcErrorMixin, Exception):
4244
4345
4446def handle_celery_errors (func ):
47+ if isasyncgenfunction (func ):
48+
49+ @wraps (func )
50+ async def async_generator_wrapper (* args , ** kwargs ):
51+ try :
52+ async for item in func (* args , ** kwargs ):
53+ yield item
54+ except CeleryError as exc :
55+ raise InternalError from exc
56+
57+ return async_generator_wrapper
58+
59+ @wraps (func )
4560 async def wrapper (* args , ** kwargs ):
4661 try :
4762 return await func (* args , ** kwargs )
You can’t perform that action at this time.
0 commit comments