@
@
@messageman2020-10-06 19:15:09
PostgreSQL
@messageman, 2020-10-06 19:15:09

Using django_rq?

I was sent a test task on Jun's backend, this is the first time I've come across the TK, but I seem to understand what they want from me. pyWHimWWRV66ECUNDPm-Zw.png
But for an asynchronous worker, django_rq is required, what is it all about? I couldn't find any documentation. For the first time I come across, isn't it easier to use Celery + Redis for asynchronous work? Please tell me, and if someone painted in stages how to complete this task, I would be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
milssky, 2020-10-06
@milssky

https://github.com/rq/django-rq

D
Dmitry, 2020-10-07
@pyHammer

messageman django_rq is much simpler than Celery.
Dock at the link .
Just like Celery, django_rq needs Redis.
To work with Django inside a task, you will need to do something like this, usually I use a decorator

# decorators.py

import os
from functools import wraps

import django

def standalone(function):
    @wraps(function)
    def _wrapper(*args, **kwargs):
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conf.settings')
        django.setup()
        return function(*args, **kwargs)
    return _wrapper

the tasks themselves are in tasks.py
# tasks.py

from .decorators import standalone

@standalone
def task(*args, **kwargs)
    pass

Something like this.
The rest is all on the docks yuzatsya.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question