Python supprocess process.stdout.readline()冻结程序

Python supprocess process.stdout.readline()冻结程序,python,minecraft,Python,Minecraft,我试图让python程序与我托管的minecraft服务器通信,但我发现的问题是,当控制台从服务器输出时,它冻结了程序。我使用的是子流程中的Popen和PIPE,每当我使用process.stdout.readline()时,它都会打印所有的行,当它完成时,它会冻结程序,然后我就无法执行更多的命令了 def start(cmd): try: process = Popen(cmd, stdin=PIPE, stdout=PIPE) except Exception

我试图让python程序与我托管的minecraft服务器通信,但我发现的问题是,当控制台从服务器输出时,它冻结了程序。我使用的是子流程中的Popen和PIPE,每当我使用process.stdout.readline()时,它都会打印所有的行,当它完成时,它会冻结程序,然后我就无法执行更多的命令了

def start(cmd):
    try:
        process = Popen(cmd, stdin=PIPE, stdout=PIPE)
    except Exception as e:
        print(e)
    return process
start('java -Xmx1024M -Xms1024M -jar server.jar nogui') # runs the minecraft server with 8GB of RAM
while True:
    print(process.stdout.readline()) # prints out every line in the server console
    readmail() # the program checks email for commands, and enters the command into the console using stdin
我试过这个:

def start(cmd):
    try:
        process = Popen(['python', '-u', cmd], stdin=PIPE, stdout=PIPE)
    except Exception as e:
        print(e)
    return process
它修复了
process.stdout.readline()
的问题,但它给了我一个错误,因为该命令是用cmd调用的,而不是用python调用的。有人知道如何用
readline()
解决这个问题吗