1

I run django web in development mode in windows powershell on windows server. I had some issues to make different tasks with different priorities, and run them in parallel instead of one by one.

  1. Tried to include "priority=1" in @background, it reported errors about no such parameters. @background(schedule=0, queue='1-qc-queue', priority=1)

  2. I even run two queue like "1-queue" and "2-queue" in two windows powershell "python manage.py process_tasks --queue 1-queue" "python manage.py process_tasks --queue 2-queue"

but I saw all tasks are always with "priority=0" in background tasks table.

  1. Tried to run multiple tasks in parallel: BACKGROUND_TASK_RUN_ASYNC = True but window powershell quit immediately

2 Answers 2

3

Late answer but this question pops up first when googling for an answer to this question and isn't really addressed in the documentation.

To set the priority you send the priority as a kwarg to the task itself.

Example: in tasks.py

@background(schedule=1) def name(name): print(name) 

in file calling task:

.... name('brian', priority=5) .... 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. i will try it later. Do you use Huey and Redis together in windows environment? I am considering trying that since it seems be documented better than background tasks.
2

To set priority for a task:

First, make the function a background task

@background(schedule=10) def func(params): return 

Now, set priority while calling the function:

func(params, priority=1) 

You can also set negative priority:

func(params, priority='-1') 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.