def set_process_at_record_id(record_id): """ 设置最近一次处理的record_id :return: """ process_at = get_process_at_record_id() if record_id > process_at: redis.set(PAY_NOTIFY_PROCESS_AT_RECORD_ID, record_id) return True return False
def set_process_at_record_id(record_id): """ 设置最近一次处理的record_id :return: """ process_at = get_process_at_record_id() if int(record_id) > process_at: redis.set(PAY_NOTIFY_PROCESS_AT_RECORD_ID, record_id) return True return False
def _lock(key, wait_time=0, time_out=DEFAULT_LOCKED_TIMED_OUT, end_time=None): """ lock certain resource with KEY """ if end_time is None: end_time = time() + wait_time while True: if redis.set(key, 1, ex=time_out, nx=True): return True if time() > end_time: return False sleep(0.1)