0

I use this bit of code to start the server as a subprocess and put the stdout into a text file.

with open('serverlog.txt', 'w') as outfile:
                proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=outfile, shell=False)

and then use this to send a commmand to the subprocess via the communicate method

    if message.content[:5] == "++say":
        userMessage = message.content[6:]
        proc.communicate(input=f"say {userMessage}".encode())

but once this block of code is reached, the program hangs.

Akliph
  • 15
  • 1
  • 4
  • `proc.communicate(...)` wait for `proc` to terminate, whereafter its `stdout` and `stderr` output is made available for your main process. I doubt that is what you want here? – JohanL Aug 29 '20 at 10:55
  • @JohanL Yeah i dont want the process to terminate, but i still need to be able to send stuff to the stdin. Is there a separate method that doesn't require the process to terminate? – Akliph Aug 30 '20 at 23:21

0 Answers0