开发者

how can I put a process in background using django?

开发者 https://www.devze.com 2022-12-31 15:27 出处:网络
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

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....

0

精彩评论

暂无评论...
验证码 换一张
取 消