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 pro开发者_Python百科cess from django application.
Try to use celery. It was originally created for this purpose and also supports scheduling tasks.
The subprocess module gives you much finer-grained control over spawning processes than afforded by os.system.
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.
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....
精彩评论