spawnl和waitpid [英] spawnl and waitpid

查看:71
本文介绍了spawnl和waitpid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我在Apache下运行一个python cgi脚本...


当脚本运行时我想显示a请等待

消息,直到脚本完成。


我试图这样做,但是请等待消息出现在

脚本末尾(此时没用!)


这里我的脚本:

--- -------------------------------------------------- -------------------------------------------

def get_ret(状态):

signal = status& 0xff

如果信号== 0:

retcode = status> 8

else:

retcode = 0

返回信号,重新编码


pidActuel = os.spawnl(os.P_NOWAIT," c:\\python25 \

\ python.exe"," python"," Main.py")


if(get_ret(os.waitpid(pidActuel,0))[1] == 0):

print"""结束"

else:

print"""请稍等..."""


--------------------------- -------------------------------------------------- --------------------

解决方案



i忘了...

感谢您的帮助:)


-----开始PGP签名留言 - ----

哈希:SHA1

na **** **** @gmail.com 写道:


你好,


我运行python cgi脚本在Apache下......


并且在脚本运行时我希望在脚本完成之前显示请稍候

消息。


我试图这样做,但是请等待消息出现在

脚本端(此时没用!)



打印消息后应刷新sys.stdout,或者

消息将保留在缓冲区中,直到缓冲区已满或处理

终止。

- -

思想家李 - th*****@branda.to th ******** @ gmail.com
http://heaven.branda.to/~thinker/GinGin_CGI.py

----- BEGIN PGP SIGNATURE-- ---

版本:GnuPG v1.4.6(FreeBSD)

评论:将GnuPG与Mozilla一起使用 - http://enigmail.mozdev.org

iD8DBQFF5Afi1LDUVnWfY8gRAgaoAJ9fccAjo00QupE7SRFqgb mOUGZMugCgjvdH

cFoxm + jiZiIpKOfd + fHCt / M =

= 9COv

-----结束PGP签名-----


27fév,11:28,Thinker< thin ... @ branda.towrote:


-----开始PGP签名消息-----

哈希:SHA1


naima.m ... @ gmail.com写道:


hello,


我在Apache下运行python cgi脚本...


并且在脚本运行时我想在脚本完成之前显示请稍候

消息。


我试过这样做,但是请等待消息出现在

脚本端(此时没用!)



打印消息后应刷新sys.stdout,或者

消息将保留在缓冲区中,直到缓冲区已满或处理

终止。


- -

思想家李 - 瘦...... @ branda.to思想家... @ gmail.comhttp://heaven.branda.to/~thinker/GinGin_CGI.py

---- -BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.6(FreeBSD)

评论:使用GnuPG和Mozilla -http://enigmail.mozdev.org


iD8DBQFF5Afi1LDUVnWfY8gRAgaoAJ9fccAjo00QupE7SRFqgb mOUGZMugCgjvdH

cFoxm + jiZiIpKOfd + fHCt / M =

= 9COv

- ---结束PGP SIGNATURE -----



你好


感谢您的回答

i有这样的冲洗,但结果相同..服务器等到

结束...


pid = os.spawnl(os.P_NOWAIT,& ; c:\\python25 \

\\ python.exe"," python"," Main.py")

sys.stdout.flush()

ret = os.waitpid(pid,0)


if(ret [1]!= 0):

print"""等待%i""" %ret [1]

sys.stdout.flush()

else:

print"""结束%i""" %ret [1]

sys.stdout.flush()


hello,

I run a python cgi script under Apache...

and while the script is running i want to display a "please wait"
message until the script finish.

I have tried to do this but the "please wait" message appears at the
script end (which is useless at this time! )

here my script:
------------------------------------------------------------------------------------------------
def get_ret(status):
signal = status & 0xff
if signal == 0:
retcode = status >8
else:
retcode = 0
return signal,retcode

pidActuel = os.spawnl(os.P_NOWAIT,"c:\\python25\
\python.exe","python","Main.py")

if ( get_ret(os.waitpid(pidActuel,0))[1] == 0 ):
print """ END"""
else:
print """ please wait... """

-------------------------------------------------------------------------------------------------

解决方案


i forgot ...
thanks for any help :)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

na********@gmail.com wrote:

hello,

I run a python cgi script under Apache...

and while the script is running i want to display a "please wait"
message until the script finish.

I have tried to do this but the "please wait" message appears at
the script end (which is useless at this time! )

You should flush sys.stdout after you print messages, or
the message will keep in buffer untill buffer is full or process
terminated.
- --
Thinker Li - th*****@branda.to th********@gmail.com
http://heaven.branda.to/~thinker/GinGin_CGI.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF5Afi1LDUVnWfY8gRAgaoAJ9fccAjo00QupE7SRFqgb mOUGZMugCgjvdH
cFoxm+jiZiIpKOfd+fHCt/M=
=9COv
-----END PGP SIGNATURE-----


On 27 fév, 11:28, Thinker <thin...@branda.towrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

naima.m...@gmail.com wrote:

hello,

I run a python cgi script under Apache...

and while the script is running i want to display a "please wait"
message until the script finish.

I have tried to do this but the "please wait" message appears at
the script end (which is useless at this time! )


You should flush sys.stdout after you print messages, or
the message will keep in buffer untill buffer is full or process
terminated.

- --
Thinker Li - thin...@branda.to thinker...@gmail.comhttp://heaven.branda.to/~thinker/GinGin_CGI.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

iD8DBQFF5Afi1LDUVnWfY8gRAgaoAJ9fccAjo00QupE7SRFqgb mOUGZMugCgjvdH
cFoxm+jiZiIpKOfd+fHCt/M=
=9COv
-----END PGP SIGNATURE-----

Hello

thanks for answering
i have flush like this but same result .. the server wait until the
end...

pid = os.spawnl(os.P_NOWAIT,"c:\\python25\
\python.exe","python","Main.py")
sys.stdout.flush()
ret = os.waitpid(pid,0)

if ( ret[1] != 0):
print """ wait %i """ %ret[1]
sys.stdout.flush()
else:
print """ end %i """ %ret[1]
sys.stdout.flush()


这篇关于spawnl和waitpid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆