Skip to content
Snippets Groups Projects
Commit 18f7e400 authored by Timothe Jost's avatar Timothe Jost
Browse files

forgot to update refresh times

parent 89d7c261
No related branches found
No related tags found
No related merge requests found
Pipeline #127759 passed
__version__ = "0.0.46" __version__ = "0.0.47"
from . import loggs from . import loggs
from .pipes import * from .pipes import *
......
...@@ -401,14 +401,16 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery | ...@@ -401,14 +401,16 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
from datetime import datetime, timedelta from datetime import datetime, timedelta
auto_refresh_time = timedelta(0, (20 * 1)) # a full day (24 hours of 3600 seconds) auto_refresh_time = timedelta(0, (3600 * 24)) # a full day (24 hours of 3600 seconds)
failed_refresh_retry_time = timedelta(0, (30 * 1)) # try to refresh after an hour failed_refresh_retry_time = timedelta(0, (60 * 5)) # try to refresh after 5 minutes
app_task_data = getattr(self, "task_data", None) app_task_data = getattr(self, "task_data", None)
if app_task_data is None: if app_task_data is None:
try: try:
task_data = self.tasks[f"{app_name}.tasks_infos"].delay(app_name).get(timeout=2) task_data = self.tasks[f"{app_name}.tasks_infos"].delay(app_name).get(timeout=10)
# we set timeout to 10 sec if the task data doesn't exist.
# It's long to wait for a webpage to load, but sometimes the workers take time to come out of sleep
app_task_data = {"task_data": task_data, "refresh_time": datetime.now() + auto_refresh_time} app_task_data = {"task_data": task_data, "refresh_time": datetime.now() + auto_refresh_time}
setattr(self, "task_data", app_task_data) setattr(self, "task_data", app_task_data)
logger.warning("Got tasks data for the first time since django server relaunched") logger.warning("Got tasks data for the first time since django server relaunched")
...@@ -424,6 +426,7 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery | ...@@ -424,6 +426,7 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
if refresh: if refresh:
try: try:
task_data = self.tasks[f"{app_name}.tasks_infos"].delay(app_name).get(timeout=2) task_data = self.tasks[f"{app_name}.tasks_infos"].delay(app_name).get(timeout=2)
# if the data needs to be refreshed, we don't wait for as long as for a first get of infos.
app_task_data = {"task_data": task_data, "refresh_time": datetime.now() + auto_refresh_time} app_task_data = {"task_data": task_data, "refresh_time": datetime.now() + auto_refresh_time}
logger.warning("Refreshed celery tasks data sucessfully") logger.warning("Refreshed celery tasks data sucessfully")
except Exception as e: except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment