From 80193114909a3f6ca1eda9a47b6330ef249a8ee5 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 18 Nov 2022 17:24:43 -0700 Subject: Deployment re-jiggling --- stator/runner.py | 6 +++--- stator/views.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'stator') diff --git a/stator/runner.py b/stator/runner.py index 187aa47..bb1b009 100644 --- a/stator/runner.py +++ b/stator/runner.py @@ -19,9 +19,9 @@ class StatorRunner: def __init__( self, models: List[Type[StatorModel]], - concurrency: int = 30, - concurrency_per_model: int = 5, - run_period: int = 30, + concurrency: int = 50, + concurrency_per_model: int = 10, + run_period: int = 60, wait_period: int = 30, ): self.models = models diff --git a/stator/views.py b/stator/views.py index ef09b8e..9d2e154 100644 --- a/stator/views.py +++ b/stator/views.py @@ -1,8 +1,9 @@ -from django.http import HttpResponse +from django.conf import settings +from django.http import HttpResponse, HttpResponseForbidden from django.views import View +from stator.models import StatorModel from stator.runner import StatorRunner -from users.models import Follow class RequestRunner(View): @@ -12,6 +13,11 @@ class RequestRunner(View): """ async def get(self, request): - runner = StatorRunner([Follow]) + # Check the token, if supplied + if settings.STATOR_TOKEN: + if request.GET.get("token") != settings.STATOR_TOKEN: + return HttpResponseForbidden() + # Run on all models + runner = StatorRunner(StatorModel.subclasses) handled = await runner.run() return HttpResponse(f"Handled {handled}") -- cgit v1.2.3