Convertido en configurables los tiempos de espera de los servicios.
This commit is contained in:
parent
99d5d36bf4
commit
29f7401c71
5 changed files with 12 additions and 12 deletions
|
|
@ -8,21 +8,18 @@ import datetime
|
|||
from db_layer.capturing_tasks_interface import capturing_interface
|
||||
from db_layer.capturas_interface import capturas_interface
|
||||
from core.scrapping_utils import UrlAttack
|
||||
from core.config import working_hours, minimum_seconds_between_tries
|
||||
from refresher.refresher import Refresher
|
||||
|
||||
|
||||
class Capturer:
|
||||
sleep_time_no_work = 60
|
||||
minimum_seconds_between_tries = 120
|
||||
working_hours = {'start': datetime.time(9, 0, 0),
|
||||
'end': datetime.time(21, 0, 0)}
|
||||
|
||||
def start(self):
|
||||
|
||||
while True:
|
||||
|
||||
if (capturing_interface.get_pending_task() is None
|
||||
or capturing_interface.seconds_since_last_try() < Capturer.minimum_seconds_between_tries
|
||||
or capturing_interface.seconds_since_last_try() < minimum_seconds_between_tries
|
||||
or not self.in_working_hours()):
|
||||
sleep(Capturer.sleep_time_no_work)
|
||||
continue
|
||||
|
|
@ -39,7 +36,7 @@ class Capturer:
|
|||
task._update_status('Captura inserted')
|
||||
|
||||
def in_working_hours(self):
|
||||
return Capturer.working_hours['start'] <= datetime.datetime.now().time() <= Capturer.working_hours['end']
|
||||
return working_hours['start'] <= datetime.datetime.now().time() <= working_hours['end']
|
||||
|
||||
|
||||
class CapturingTask:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue