def is_timeout(ex, op_name=None):
"""Check the exception to determine if it is a Boto3 ClientError
thrown because the task timed out.
Args:
ex (Exception) : Exception to check
op_name (string|None) : (Optional) name of the operation that was attempted
Returns:
bool : If the exception was caused by the task timing out
"""
try:
rst = ex.response['Error']['Code'] == 'TaskTimedOut'
if op_name:
rst &= ex.operation_name == op_name
return rst
except:
return False
评论列表
文章目录