Esempio n. 1
0
__author__ = '*****@*****.**'

import uuid

from celery.exceptions import TimeoutError
from celery.result import AsyncResult
from rest_framework.decorators import detail_route
from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_201_CREATED

from core.utils.logging import getPrettyLogger

logger = getPrettyLogger(__name__)


class CreateCeleryMixin():
    @detail_route()
    def check(self, request, *args, **kwargs):

        try:
            task_id = request.data['id']
            uuid.UUID(task_id)
        except KeyError:
            raise ValidationError("You should specify id")
        except ValueError:
            raise ValidationError("Not valid id")

        async_result = AsyncResult(task_id)

        try:
Esempio n. 2
0
__author__ = '*****@*****.**'

import uuid

from celery.exceptions import TimeoutError
from celery.result import AsyncResult
from rest_framework.decorators import detail_route
from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.status import HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_201_CREATED

from core.utils.logging import getPrettyLogger

logger = getPrettyLogger(__name__)


class CreateCeleryMixin():
    @detail_route()
    def check(self, request, *args, **kwargs):

        try:
            task_id = request.data['id']
            uuid.UUID(task_id)
        except KeyError:
            raise ValidationError("You should specify id")
        except ValueError:
            raise ValidationError("Not valid id")

        async_result = AsyncResult(task_id)

        try: