def handle_twitter_http_error(e, error_count, call_counter, time_window_start, wait_period):
    """
    This function handles the twitter request in case of an HTTP error.

    Inputs:  - e: A twython.TwythonError instance to be handled.
             - error_count: Number of failed retries of the call until now.
             - call_counter: A counter that keeps track of the number of function calls in the current 15-minute window.
             - time_window_start: The timestamp of the current 15-minute window.
             - wait_period: For certain Twitter errors (i.e. server overload), we wait and call again.

    Outputs: - call_counter: A counter that keeps track of the number of function calls in the current 15-minute window.
             - time_window_start: The timestamp of the current 15-minute window.
             - wait_period: For certain Twitter errors (i.e. server overload), we wait and call again.

    Raises: - twython.TwythonError
    """
    if e.error_code == 401:
        # Encountered 401 Error (Not Authorized)
        raise e
    elif e.error_code == 404:
        # Encountered 404 Error (Not Found)
        raise e
    elif e.error_code == 429:
        # Encountered 429 Error (Rate Limit Exceeded)
        # Sleep for 15 minutes
        error_count += 0.5
        call_counter = 0
        wait_period = 2
        time.sleep(60*15 + 5)
        time_window_start = time.perf_counter()
        return error_count, call_counter, time_window_start, wait_period
    elif e.error_code in (500, 502, 503, 504):
        error_count += 1
        time.sleep(wait_period)
        wait_period *= 1.5
        return error_count, call_counter, time_window_start, wait_period
    else:
        raise e
def handle_twitter_http_error ( e , error_count , call_counter , time_window_start , wait_period ) : if e . error_code == 401 : raise e elif e . error_code == 404 : raise e elif e . error_code == 429 : error_count += 0.5 call_counter = 0 wait_period = 2 time . sleep ( 60 * 15 + 5 ) time_window_start = time . perf_counter ( ) return error_count , call_counter , time_window_start , wait_period elif e . error_code in ( 500 , 502 , 503 , 504 ) : error_count += 1 time . sleep ( wait_period ) wait_period *= 1.5 return error_count , call_counter , time_window_start , wait_period else : raise e
This function handles the twitter request in case of an HTTP error.

    Inputs:  - e: A twython.TwythonError instance to be handled.
             - error_count: Number of failed retries of the call until now.
             - call_counter: A counter that keeps track of the number of function calls in the current 15-minute window.
             - time_window_start: The timestamp of the current 15-minute window.
             - wait_period: For certain Twitter errors (i.e. server overload), we wait and call again.

    Outputs: - call_counter: A counter that keeps track of the number of function calls in the current 15-minute window.
             - time_window_start: The timestamp of the current 15-minute window.
             - wait_period: For certain Twitter errors (i.e. server overload), we wait and call again.

    Raises: - twython.TwythonError