Skip to content Skip to sidebar Skip to footer

How Can I Put A Process In Background Using Django?

I tried os.system, os.spwanl, etc.. but it doesn't work well I need to execute some background process from django application.

Solution 1:

Try to use celery. It was originally created for this purpose and also supports scheduling tasks.

Solution 2:

The subprocess module gives you much finer-grained control over spawning processes than afforded by os.system.

Solution 3:

I have used subprocess to spawn background processes from Django before. It may depend on your environment, but I had no issue using it with both modpython and modwsgi.

Solution 4:

I've used paramiko to put the process in background for localhost/remote hots..,

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host,user,pwd,port,.......)

si, so, se = ssh.exec_command('nohup' + cmd + '&')
so.read()
se.read()

has resolved the issue....

Post a Comment for "How Can I Put A Process In Background Using Django?"