Weird waiting distribution implemented
This commit is contained in:
parent
df032328e9
commit
af11a2e87f
2 changed files with 9 additions and 4 deletions
|
|
@ -26,7 +26,7 @@ class Capturer:
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
if (
|
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()
|
or not self.in_working_hours()
|
||||||
):
|
):
|
||||||
sleep(Capturer.sleep_time_no_work)
|
sleep(Capturer.sleep_time_no_work)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from os import environ
|
from os import environ
|
||||||
import datetime
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
# TODO Use dot_env to properly configure all of this.
|
# TODO Use dot_env to properly configure all of this.
|
||||||
|
|
||||||
|
|
@ -31,9 +32,13 @@ try:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
current_db_parameters = databases["default"]
|
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
|
monthly_new_ads_target = 1200
|
||||||
google_api_key = "AIzaSyCnKj0WnsxVZcaoxeAYkuRw3cKRNGiISYA"
|
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
|
geocoder_delay = 10
|
||||||
refresher_delay = 10
|
refresher_delay = 10
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue