remove celery and use dramatiq

This commit is contained in:
virusdefender
2019-03-11 16:21:29 +08:00
parent 1af50c0f4c
commit a5f0c8eb31
16 changed files with 65 additions and 61 deletions

View File

@@ -1,7 +1,6 @@
import functools
import json
import logging
from collections import OrderedDict
from django.http import HttpResponse, QueryDict
from django.utils.decorators import method_decorator
@@ -98,6 +97,8 @@ class APIView(View):
elif isinstance(errors, list):
return self.extract_errors(errors[0], key)
return key, errors
def invalid_serializer(self, serializer):
key, error = self.extract_errors(serializer.errors)
if key == "non_field_errors":

View File

@@ -81,3 +81,7 @@ def send_email(smtp_config, from_name, to_email, to_name, subject, content):
def get_env(name, default=""):
return os.environ.get(name, default)
def DRAMATIQ_WORKER_ARGS(time_limit=3600_000, max_retries=0, max_age=7200_000):
return {"max_retries": max_retries, "time_limit": time_limit, "max_age": max_age}

View File

@@ -1,8 +1,10 @@
import os
from celery import shared_task
import dramatiq
from utils.shortcuts import DRAMATIQ_WORKER_ARGS
@shared_task
@dramatiq.actor(**DRAMATIQ_WORKER_ARGS())
def delete_files(*args):
for item in args:
try: