fromtypingimportAny,Callable,Optional,Union,List,Literalimportasyncioimportloggingfromdataclassesimportdataclass# Type for error handling actionsErrorAction=Literal["fail","skip_item","skip_batch"]
[docs]@dataclassclassRetryConfig:"""Configuration for retry behavior."""max_attempts:int=3base_delay:float=1.0# secondsexponential_backoff:bool=Truemax_delay:float=60.0# secondsbackoff_multiplier:float=2.0
[docs]classErrorHandler:"""Base class for custom error handlers."""
[docs]asyncdefhandle_error(self,error:Exception,item:Any,task_name:str,attempt:int)->tuple[bool,Any]:""" Handle an error and return (should_continue, value). Returns: tuple: (should_continue, value) - should_continue: True to continue pipeline, False to raise - value: Value to use (only relevant if should_continue is True) """raiseNotImplementedError
[docs]classLoggingErrorHandler(ErrorHandler):"""Error handler that logs errors and continues."""