diff options
Diffstat (limited to 'stator')
-rw-r--r-- | stator/runner.py | 6 | ||||
-rw-r--r-- | stator/views.py | 12 |
2 files changed, 12 insertions, 6 deletions
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}") |