嗨,使用时标准输出读取有问题子流程.Popen在
daniel@desktop:~$ python -V
Python 2.7.3
代码如下:(注释代码是我尝试过的一些东西)
^{pr2}$这是我连接到服务器并断开连接时得到的输出:
daniel@desktop:~/hlds$ python hlds.py
Auto detecting CPU
Using breakpad crash handler
Using Pentium II Optimised binary.
Setting breakpad minidump AppID = 10
Auto-restarting the server on crash
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Console initialized.
Calling BreakpadMiniDumpSystemInit
scandir failed:/home/daniel/hlds/./valve/SAVE
Installing breakpad exception handler for appid(10)/version(5447)
scandir failed:/home/daniel/hlds/./platform/SAVE
Looking up breakpad interfaces from steamclient
Protocol version 48
Calling BreakpadMiniDumpSystemInit
while循环在以下时间后锁定:
Calling BreakpadMiniDumpSystemInit.
但服务器仍在运行,我可以连接,运行命令等。。。在
如果我跑:
./hlds_run -game cstrike -maxplayers 11 >> stdout.log 2>&1
我得到以下输出标准输出日志公司名称:
daniel@desktop:~/hlds$ cat stdout.log
Auto detecting CPU
Using Pentium II Optimised binary.
Auto-restarting the server on crash
Console initialized.
Using breakpad crash handler
Setting breakpad minidump AppID = 10
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Installing breakpad exception handler for appid(10)/version(5447)
scandir failed:/home/daniel/hlds/./valve/SAVE
scandir failed:/home/daniel/hlds/./platform/SAVE
Protocol version 48
Exe version 1.1.2.6/Stdio (cstrike)
Exe build: 14:06:24 Sep 23 2011 (5447)
STEAM Auth Server
Server IP address 127.0.1.1:27015
couldn't exec listip.cfg
couldn't exec banned.cfg
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
scandir failed:/home/daniel/hlds/./valve/SAVE
scandir failed:/home/daniel/hlds/./platform/SAVE
Could not establish connection to Steam servers.
Reconnected to Steam servers.
VAC secure mode is activated.
ERROR: couldn't open custom.hpk.
JAMES HETFIELD : hello!
Dropped JAMES HETFIELD from server
Reason: Client sent 'drop'
Sat Apr 14 00:10:54 CEST 2012: Server Quit
但是,如果不执行2>;&1,则仍会在stdout中获取此输出,而其他输出则会在标准输出日志公司名称:
daniel@desktop:~/hlds$ ./hlds_run -game cstrike -maxplayers 11 >> stdout.log
Using breakpad crash handler
Setting breakpad minidump AppID = 10
Forcing breakpad minidump interfaces to load
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Installing breakpad exception handler for appid(10)/version(5447)
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
尝试创建servermanager和dispatcher作为子流程学习体验:]
感谢大家的帮助!:)
结果是其中一个管道被数据填满,从而阻塞了子进程,而python进程在试图从另一个管道中读取一行时被阻塞,从而导致死锁。您可能希望使用某种轮询(select/poll/epoll),而不是对管道执行阻塞读取。在
一种快速的方法是在while循环中执行非阻塞读取,但这将导致python进程使用大量CPU。在
请参阅select模块的文档,以了解有关以非黑客方式解决问题的更多信息。在
你能用select解决这个问题吗?我发现当我启动SRCDS时,即使是非阻塞,它也不会经过“调用BreakpadMiniDumpSystemInit”:
这将打印到“BreakpadMiniDumpSystemInit”消息,进一步调用read()抛出“Resource temporary unavailable”,直到有内容写入p.stdin。在
相关问题 更多 >
编程相关推荐