Skip to content

Commit 7364b33

Browse files
c4llouspandafy
andauthored
[change] Added time limits to celery tasks #608
Closes #608 Co-authored-by: Gagan Deep <pandafy.dev@gmail.com>
1 parent 0eea90a commit 7364b33

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

openwisp_controller/config/tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from django.core.exceptions import ObjectDoesNotExist
88
from swapper import load_model
99

10+
from openwisp_utils.tasks import OpenwispCeleryTask
11+
1012
logger = logging.getLogger(__name__)
1113

1214

@@ -54,7 +56,7 @@ def create_vpn_dh(vpn_pk):
5456
vpn.save()
5557

5658

57-
@shared_task
59+
@shared_task(base=OpenwispCeleryTask)
5860
def invalidate_devicegroup_cache_change(instance_id, model_name):
5961
from .api.views import DeviceGroupCommonName
6062

@@ -70,7 +72,7 @@ def invalidate_devicegroup_cache_change(instance_id, model_name):
7072
DeviceGroupCommonName.certificate_change_invalidates_cache(instance_id)
7173

7274

73-
@shared_task
75+
@shared_task(base=OpenwispCeleryTask)
7476
def invalidate_devicegroup_cache_delete(instance_id, model_name, **kwargs):
7577
from .api.views import DeviceGroupCommonName
7678

@@ -87,7 +89,7 @@ def invalidate_devicegroup_cache_delete(instance_id, model_name, **kwargs):
8789
)
8890

8991

90-
@shared_task(soft_time_limit=1200)
92+
@shared_task(base=OpenwispCeleryTask)
9193
def trigger_vpn_server_endpoint(endpoint, auth_token, vpn_id):
9294
response = requests.post(
9395
endpoint,

openwisp_controller/subnet_division/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from django.utils.translation import gettext_lazy as _
66
from swapper import load_model
77

8+
from openwisp_utils.tasks import OpenwispCeleryTask
9+
810
logger = logging.getLogger(__name__)
911

1012
Subnet = load_model('openwisp_ipam', 'Subnet')
@@ -69,7 +71,7 @@ def update_subnet_name_description(rule_id):
6971
)
7072

7173

72-
@shared_task
74+
@shared_task(base=OpenwispCeleryTask)
7375
def provision_extra_ips(rule_id, old_number_of_ips):
7476
def _create_ipaddress_and_subnetdivision_index_objects(ips, indexes):
7577
IpAddress.objects.bulk_create(ips)

0 commit comments

Comments
 (0)