在自己电脑上是好的,但是移植到windows2003的服务器上运行的时候每次就会卡着这行代码这里不能正常执行。
搜寻资料中发现有如下解释(参考):
It appears that subprocess calls a module global "_cleanup()" whenever opening a new subprocess. This method is meant to reap any child processes that have terminated and have not explicitly cleaned up. These are processes you would expect to be cleaned up by GC, however, subprocess keeps a list of of all spawned subprocesses in _active until they are reaped explicitly so it can cleanup any that nolonger referenced anywhere else.The problem is lots of methods, including poll() and wait(), check self.returncode and then modify it. Any non-atomic read/modify action is inherently non-threadsafe. And _cleanup() calls poll() on all un-reaped child processes. If two threads happen to try and spawn subprocesses at once, these _cleanup() calls collide..The way to fix this depends on how thread-safe you want to make it. If you want to share popen objects between threads to wait()/poll() with impunity from any thread, you should add a recursive lock attribute to the Popen instance and have it lock/release it at the start/end of every method call.
其他相关资料:
----------------------12月10日更新分割线---------------------------
结果:就是程序的问题,或者更明确地说是child子程序的问题。所以说,程序的世界里是没有未解之谜的,一切都是有据可循的,如果出现了奇怪的错误,只需要默默好好的检查自己代码。