Home > other >  Django development of celery, celery task how to use Models
Django development of celery, celery task how to use Models

Time:09-20

I want to use in development use django + implementations of asynchronous task queue, celery way users to upload files to django django model after a new task for celery,
 task_id=my_task. Delay (my_model. Id) 

In the task for the following operations:
 @ app. Task 
Def my_task (id) :
The file=my_model. Objects. The get (id=id)

But will quote us the following error:
 django. Db. Utils. DatabaseError: DatabaseWrapper objects created in a thread can only be 2 in that same thread. The object with The alias' default 'was created in 2662856759904 and this is The thread id thread id 2660784454544. 


Look mean in one thread to create the object cannot be used to other threads, and don't know if I use in the right way, you have fall over the same questions? Everyone is how to solve?

CodePudding user response:

I get a preliminary solution, reference to you, hope each master can help me to find a final solution
https://blog.csdn.net/mike198300/article/details/105612288
  • Related