Exemple #1
0
def get_poe_trade_main_lowest_timestamp(
        poe_trade_main_handler_classes_list):
    """
    Function gets lowest checked_timestamp in list
    :param poe_trade_main_handler_classes_list: list with instances of PoeTradeMainHandler
    :return: position in list which has lowest checked_timestamp or
            None if no one is ready to work (checked_timestamp is lower than THREAD_SLEEP_DELAY_BETWEEN_CHECKS_SEC)
    """
    position = None

    for index in range(0, len(poe_trade_main_handler_classes_list)):
        # Is class already working?
        if not poe_trade_main_handler_classes_list[index].working:
            if position is None:
                position = index
                continue
            # Class not working at this moment. Lets check timestamp
            current_class_timestamp = poe_trade_main_handler_classes_list[position].checked_timestamp
            index_class_timestamp = poe_trade_main_handler_classes_list[index].checked_timestamp

            if index_class_timestamp < current_class_timestamp:
                position = index

    if position is not None:
        class_timestamp = poe_trade_main_handler_classes_list[position].checked_timestamp
        timestamp_diff = time.time() - class_timestamp

        if timestamp_diff > Settings.thread_sleep_delay_between_checks_sec():
            return position

    return None