Weird waiting distribution implemented

This commit is contained in:
pablo 2020-04-26 14:54:27 +02:00
parent df032328e9
commit af11a2e87f
2 changed files with 9 additions and 4 deletions

View file

@ -26,7 +26,7 @@ class Capturer:
while True:
if (
self.seconds_since_last_try() < minimum_seconds_between_tries
self.seconds_since_last_try() < minimum_seconds_between_tries()
or not self.in_working_hours()
):
sleep(Capturer.sleep_time_no_work)

View file

@ -1,5 +1,6 @@
from os import environ
import datetime
import random
# TODO Use dot_env to properly configure all of this.
@ -31,9 +32,13 @@ try:
except KeyError:
current_db_parameters = databases["default"]
working_hours = {"start": datetime.time(9, 0, 0), "end": datetime.time(21, 0, 0)}
working_hours = {"start": datetime.time(9, 0, 0), "end": datetime.time(23, 0, 0)}
monthly_new_ads_target = 1200
google_api_key = "AIzaSyCnKj0WnsxVZcaoxeAYkuRw3cKRNGiISYA"
minimum_seconds_between_tries = 60
def seconds_generator():
return max(random.randint(120, 360) + random.normalvariate(0, 120), random.randint(10, 20))
minimum_seconds_between_tries = seconds_generator
geocoder_delay = 10
refresher_delay = 10