def _is_known_retryable(exception):
 if isinstance(exception, APIError):
  if (exception.response.status_code == INTERNAL_SERVER_ERROR):
   error_text = exception.response.text
   return any(((known in error_text) for known in [u'Unknown device', u'no such device']))
 if isinstance(exception, ConnectionError):
  if ((len(exception.args) > 0) and isinstance(exception.args[0], ProtocolError)):
   if ((len(exception.args[0].args) > 1) and isinstance(exception.args[0].args[1], socket_error)):
    return (exception.args[0].args[1].errno in {ECONNREFUSED})
 return False

def _is_known_retryable ( exception ) : if isinstance ( exception , APIError ) : if ( exception . response . status_code == INTERNAL_SERVER_ERROR ) : error_text = exception . response . text return any ( ( ( known in error_text ) for known in [ u'Unknown device' , u'no such device' ] ) ) if isinstance ( exception , ConnectionError ) : if ( ( len ( exception . args ) > 0 ) and isinstance ( exception . args [ 0 ] , ProtocolError ) ) : if ( ( len ( exception . args [ 0 ] . args ) > 1 ) and isinstance ( exception . args [ 0 ] . args [ 1 ] , socket_error ) ) : return ( exception . args [ 0 ] . args [ 1 ] . errno in { ECONNREFUSED } ) return False
determine if the text of a docker 500 error represents a case which warrants an automatic retry .