Python 子进程未结束

Python 子进程未结束,python,subprocess,Python,Subprocess,我试图为python游戏创建一个启动器,但遇到了一个问题。当子进程中的代码结束时,主线程不会继续 下面是调用子进程的线程 class ClientThread(threading.Thread): def __init__(self, port, host, name, colour): super(ClientThread, self).__init__() self.port = port self.host = host

我试图为python游戏创建一个启动器,但遇到了一个问题。当子进程中的代码结束时,主线程不会继续

下面是调用子进程的线程

class ClientThread(threading.Thread):
    def __init__(self, port, host, name, colour):
        super(ClientThread, self).__init__()
        self.port = port
        self.host = host
        self.name = name
        self.colour = colour
        self.running = False
        self.toKill = False

    def run(self):
        self.running = True
        print("Started")
        args = self.host+" "+str(self.port)+" "+self.name.replace(" ", "_")+" "+str(self.colour[0])+" "+str(self.colour[1])+" "+str(self.colour[2])
        subprocess.call("C:\Python33\python.exe Client.py "+args)
        print("DONE CLIENT")
        self.toKill = True
print("NOTHING")
sock.close()
print("Socket")
try:
    gc.join(0.5)
    print("Threads")
except:
    print("ERROR")
pygame.quit()
print("Pygame")
exit(0)
下面是子流程末尾的代码

class ClientThread(threading.Thread):
    def __init__(self, port, host, name, colour):
        super(ClientThread, self).__init__()
        self.port = port
        self.host = host
        self.name = name
        self.colour = colour
        self.running = False
        self.toKill = False

    def run(self):
        self.running = True
        print("Started")
        args = self.host+" "+str(self.port)+" "+self.name.replace(" ", "_")+" "+str(self.colour[0])+" "+str(self.colour[1])+" "+str(self.colour[2])
        subprocess.call("C:\Python33\python.exe Client.py "+args)
        print("DONE CLIENT")
        self.toKill = True
print("NOTHING")
sock.close()
print("Socket")
try:
    gc.join(0.5)
    print("Threads")
except:
    print("ERROR")
pygame.quit()
print("Pygame")
exit(0)
以下是控制台输出:

ESCAPE
Connected Status
NOTHING
Socket
Threads
Pygame

最后,当线程恢复时,它应该说“clientdone”。我只想在任何系统工作的过程结束时,将
toKill
变为现实。我完全被这搞糊涂了,找不到任何帮助。提前谢谢

我认为
SystemExit
异常(来自
exit(0)
在父级内部被重新引发,导致它提前终止,即使没有该行,线程仍然无法恢复。它应该打印“DONE CLIENT”。你能展示一个吗?你可能需要所有的代码来复制它,都在github上:。启动时,在色调框中输入3位数字,然后按启动服务器。一旦它运行,按escape退出。客户端关闭,但不打印客户端完成。如果你在它自己的文件夹中运行启动器,文件将在运行时全部下载到那里。我认为这不足以重现问题。a的想法是减少代码,以便更有可能有人发现问题。也许您甚至可以自己找到它,同时减少不相关代码的数量。