1👍
Take a look at Celery, it is a distributed task queue that will handle your situation perfectly. There is a little bit of setup to get everything working but once that is out of the way Celery really easy to work with.
For integration with Django start here: http://docs.celeryproject.org/en/latest/django/index.html
👤Tim
1👍
Write a management command to for parseMsg and trigger that using subprocess.popen and return success to user and parseMsg process will run in background. if this kind of operations are more in the application then you should use celery.
👤loki
- [Django]-TypeError: the first argument must be callable when I import a scheduler in my views.py file of django?
- [Django]-Django: How does it find the User model?
1👍
This is quiet easy, encapsulate #start a new thread with the code below
from threading import Thread
from datetime import datetime
class ProcessThread(Thread):
def __init__(self, name):
Thread.__init__(self)
self.name = name
self.started = datetime.now()
def run(self):
cache_classroom(openID,arr[1],arr[2],arr[3],arr[4]).start()
# I added this so you might know how long the process lasted
# just incase any optimization of your code is needed
finished = datetime.now()
duration = (self.start - finished).seconds
print "%s thread started at %s and finished at %s in "\
"%s seconds" % (self.name, self.started, finished, duration)
# let us now run start the thread
my_thread = ProcessThread("CacheClassroom")
my_thread.start()
Source:stackexchange.com