wait 30s when BAD_GATEWAY
This commit is contained in:
@@ -7,3 +7,4 @@ class RequestResult(Enum):
|
||||
SUCCESS = "SUCCESS"
|
||||
COOKIES_ERROR = "COOKIES_ERROR"
|
||||
UNKNOWN = "UNKNOWN"
|
||||
BAD_GATEWAY = "BAD_GATEWAY"
|
||||
|
||||
@@ -103,7 +103,7 @@ class LinkValidator(threading.Thread):
|
||||
else:
|
||||
return RequestResult.UNKNOWN
|
||||
elif response.status_code == 502:
|
||||
return RequestResult.PROXY_ERROR
|
||||
return RequestResult.BAD_GATEWAY
|
||||
else:
|
||||
return RequestResult.BLOCKED
|
||||
except Exception as error:
|
||||
@@ -136,6 +136,7 @@ class LinkValidator(threading.Thread):
|
||||
random.shuffle(self.link_to_validate_list)
|
||||
if len(self.link_to_validate_list) > 0 and _message_in_queue_count > self.limit:
|
||||
print("links number is {}".format(len(self.link_to_validate_list)))
|
||||
can_continue = None
|
||||
for con in self.link_to_validate_list:
|
||||
# if not is_already_sent(con):
|
||||
print(con.email)
|
||||
@@ -145,10 +146,17 @@ class LinkValidator(threading.Thread):
|
||||
print("cannot continue, blocked, then skip")
|
||||
break
|
||||
else:
|
||||
if can_continue == RequestResult.BAD_GATEWAY:
|
||||
time.sleep(30)
|
||||
break
|
||||
time.sleep(random.randint(2, 5))
|
||||
print("can continue, continue")
|
||||
print("will ack")
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
if can_continue == RequestResult.BAD_GATEWAY or can_continue == RequestResult.PROXY_ERROR:
|
||||
print("will requeue the message")
|
||||
ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True)
|
||||
else:
|
||||
print("will ack")
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
else:
|
||||
print("empty list, no need to ack")
|
||||
time.sleep(60)
|
||||
|
||||
Reference in New Issue
Block a user