#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def get_retry_limiter( destination , clock , store , **kwargs ) : #NEWLINE# #INDENT# "For a given destination check if we have previously failed to\n    send a request there and are waiting before retrying the destination.\n    If we are not ready to retry the destination, this will raise a\n    NotRetryingDestination exception. Otherwise, will return a Context Manager\n    that will mark the destination as down if an exception is thrown (excluding\n    CodeMessageException with code < 500)\n\n    Example usage:\n\n        try:\n            limiter = yield get_retry_limiter(destination, clock, store)\n            with limiter:\n                response = yield do_request()\n        except NotRetryingDestination:\n            # We aren't ready to retry that destination.\n            raise\n    " #NEWLINE# ( retry_last_ts , retry_interval ) = ( 0 , 0 ) #NEWLINE# retry_timings = ( yield store . get_destination_retry_timings ( destination ) ) #NEWLINE# if retry_timings : #NEWLINE# #INDENT# ( retry_last_ts , retry_interval ) = ( retry_timings [ 'retry_last_ts' ] , retry_timings [ 'retry_interval' ] ) #NEWLINE# now = int ( clock . time_msec ( ) ) #NEWLINE# if ( ( retry_last_ts + retry_interval ) > now ) : #NEWLINE# #INDENT# raise NotRetryingDestination ( retry_last_ts = retry_last_ts , retry_interval = retry_interval , destination = destination ) #NEWLINE# #UNINDENT# #UNINDENT# defer . returnValue ( RetryDestinationLimiter ( destination , clock , store , retry_interval , ** kwargs ) )