def ThrottleRate(throttle_dict, max_count, time_period):
 now = GetCurrentTimestamp()
 if ((not throttle_dict) or (now >= (throttle_dict['start_time'] + time_period))):
  throttle_dict = {'start_time': now, 'count': 0}
 else:
  throttle_dict = {'start_time': throttle_dict['start_time'], 'count': throttle_dict['count']}
 if (throttle_dict['count'] >= max_count):
  return (throttle_dict, True)
 throttle_dict['count'] += 1
 return (throttle_dict, False)

def ThrottleRate ( throttle_dict , max_count , time_period ) : now = GetCurrentTimestamp ( ) if ( ( not throttle_dict ) or ( now >= ( throttle_dict [ 'start_time' ] + time_period ) ) ) : throttle_dict = { 'start_time' : now , 'count' : 0 } else : throttle_dict = { 'start_time' : throttle_dict [ 'start_time' ] , 'count' : throttle_dict [ 'count' ] } if ( throttle_dict [ 'count' ] >= max_count ) : return ( throttle_dict , True ) throttle_dict [ 'count' ] += 1 return ( throttle_dict , False )
throttle the rate at which occurrences of some event can occur .