守护蟒蛇 [英] Daemonizing python
问题描述
嗨!
我想知道是否可以将当前的python进程转换为
a unix守护进程,但不是这样做的:
python myscript.py&
但是来自代码programaticaly。
谢谢。
Hi!
I was wondering if it is possible to turn the current python proccess into
a unix daemon, but not doing it like this:
python myscript.py &
but from code programaticaly.
Thanks.
推荐答案
NinjaZombie< ni ********* @ net.hrwrites:
NinjaZombie <ni*********@net.hrwrites:
我想知道是否有可能转身将当前的python进程转换为
a unix守护进程,但不是这样做的:
python myscript.py&
但是来自代码programaticaly。
I was wondering if it is possible to turn the current python proccess into
a unix daemon, but not doing it like this:
python myscript.py &
but from code programaticaly.
是的,os.fork和父进程退出。
Yeah, os.fork and the parent process exits.
Paul Rubin写道:
Paul Rubin wrote:
NinjaZombie< ni ********* @ net.hrwrites:
NinjaZombie <ni*********@net.hrwrites:
>我想知道是否有可能将当前的python
进程转换为unix守护进程,但不是这样做的:
python myscript.py& <但是来自代码programaticaly。
>I was wondering if it is possible to turn the current python
proccess into a unix daemon, but not doing it like this:
python myscript.py &
but from code programaticaly.
是的,os.fork和父进程退出。
Yeah, os.fork and the parent process exits.
或者像twd这样的小帮手 - 只有在你使用Twisted
时才可行。
问候,
Bj?
-
BOFH借口#438:
粘性位松散
Or little helpers like twistd -- only feasible if you use Twisted
though.
Regards,
Bj?rn
--
BOFH excuse #438:
sticky bit has come loose
Na dan Sun,2006年9月24日23:19:12 +0200,Bjoern Schliessmann je napisao:
Na dan Sun, 24 Sep 2006 23:19:12 +0200, Bjoern Schliessmann je napisao:
Paul Rubin写道:
Paul Rubin wrote:
> NinjaZombie< ni ********* @ net .hrwrites:
>NinjaZombie <ni*********@net.hrwrites:
>>我想知道是否可以转动当前的python
进入一个unix守护进程,但不是这样做的:
python myscript.py&
但是来自代码programaticaly。
>>I was wondering if it is possible to turn the current python
proccess into a unix daemon, but not doing it like this:
python myscript.py &
but from code programaticaly.
>是的,os.fork和父进程退出。
>Yeah, os.fork and the parent process exits.
或者像twistd这样的小帮手 - 只有在你使用Twisted
时才可行。
Or little helpers like twistd -- only feasible if you use Twisted
though.
谢谢大家,但我对此有点新鲜。看看这个非常简单的
代码:
import os
print" Entering program"
os.fork()
而(1):
传递#其他一些工作
我在'os后被开除了.fork()'',程序的其余部分将在后台运行
,这不是。
Thanks guys, but I''m a little new to this. Take a look at this very simple
code:
import os
print "Entering program"
os.fork()
while (1):
pass # some other work
I was expexting that after ''os.fork()'', the rest of the program would run
in the background, which it isn''t.
这篇关于守护蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!