2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

Remove sleep call (#9866)

This commit is contained in:
Oliver
2025-06-26 09:52:35 +10:00
committed by GitHub
parent fd9eeb4184
commit 81113dcd99
2 changed files with 0 additions and 14 deletions

View File

@ -2,9 +2,7 @@
import json import json
import os import os
import random
import re import re
import time
import warnings import warnings
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime, timedelta from datetime import datetime, timedelta
@ -94,18 +92,12 @@ def check_daily_holdoff(task_name: str, n_days: int = 1) -> bool:
Note that this function creates some *hidden* global settings (designated with the _ prefix), Note that this function creates some *hidden* global settings (designated with the _ prefix),
which are used to keep a running track of when the particular task was was last run. which are used to keep a running track of when the particular task was was last run.
""" """
from InvenTree.ready import isInTestMode
if n_days <= 0: if n_days <= 0:
logger.info( logger.info(
"Specified interval for task '%s' < 1 - task will not run", task_name "Specified interval for task '%s' < 1 - task will not run", task_name
) )
return False return False
# Sleep a random number of seconds to prevent worker conflict
if not isInTestMode():
time.sleep(random.randint(1, 5))
attempt_key = f'_{task_name}_ATTEMPT' attempt_key = f'_{task_name}_ATTEMPT'
success_key = f'_{task_name}_SUCCESS' success_key = f'_{task_name}_SUCCESS'

View File

@ -1,7 +1,5 @@
"""Background task definitions for the 'part' app.""" """Background task definitions for the 'part' app."""
import random
import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
@ -13,7 +11,6 @@ from opentelemetry import trace
import common.currency import common.currency
import common.notifications import common.notifications
import company.models import company.models
import InvenTree.helpers
import InvenTree.helpers_model import InvenTree.helpers_model
import InvenTree.tasks import InvenTree.tasks
import part.models as part_models import part.models as part_models
@ -160,9 +157,6 @@ def scheduled_stocktake_reports():
- Delete 'old' stocktake report files after the specified period - Delete 'old' stocktake report files after the specified period
- Generate new reports at the specified period - Generate new reports at the specified period
""" """
# Sleep a random number of seconds to prevent worker conflict
time.sleep(random.randint(1, 5))
# First let's delete any old stocktake reports # First let's delete any old stocktake reports
delete_n_days = int( delete_n_days = int(
get_global_setting('STOCKTAKE_DELETE_REPORT_DAYS', 30, cache=False) get_global_setting('STOCKTAKE_DELETE_REPORT_DAYS', 30, cache=False)