Python3: Popen communication
Question: I'm a gamer, and a coder. In one of my game, minecraft, I need a server, so,
with a friend, I bought one. But, this friend doesn't understand anything of
coding and, in particular, of the Linux' bash, so he can't switch on/off our
server, and he can't work on it. So I decied to make a program that help him
with our server. The point is that the server is coded in java (it is a jar)
and I can't acces to it without external commands. So, I reed lots of docs,
and all of these docs said to me: «You must use subprocess!»!! So I used it,
but I have a BIG problem in this Popen object Note before the problem: my
program doesn't just switch on/off the server, it is a server with the
relatives clients that allow to interract with the minecraft server and it
uses some socket and threading libreries.

So, the problem is:

    
    
    class getOutput(Thread):
    def __init__(self,outProc,connection):
        self.proc = outProc                #My Popen object
        self.connection = connection       #a socket object (my server biding)
        self.stop = False                  #A way to stop this thread is to put getOutput.stop = True
        Thread.__init__(self)
    def run(self):
        proc = self.proc
        conn = self.connection
        while True:
            if self.stop:                  #if getOutput.stop = True, stop the thread
                break
            out = proc.stdout.readlines()  #My problem...
            for lines in out:
                print(out)                 #My output where the server is started
                conn.send(line)            #send to client the output of the server
    
    def StartMcServ():
        global proc, conn, outputManager, McServStarted          #Because it's a server and I must launch the minecraft server more than once
        print('[Server/Info] Started McServ!')                   #Info is always useful
        logfile.log('[Server/Info] Started McServ!')             #a librery that I created that log in a file, ignore this line
        proc = sh.Popen(JavaServ(),stdin=PIPE,stdout=PIPE,stderr=PIPE) #sh=subprocess, I did a from subprocess import PIPE,STDOUT ; import subprocess as sh because of the functions of subprocess have the same name that my libreries
        outputManager = getOutput(proc,conn)                     #My thread, that have the process and the connection
        outputManager.start()
    
    def PutInput(*,Input=None):                                  #A function that put input in my server
        if Input and type(Input) == type(b'') and Input.endswith(b'\n'):
            proc.stdin.write(Input)
    

so, **I really don't know** what is the problem, but the communication with
the server doesn't work, I'm sooooo sad of it

_P.S.: I dont put all the program or the main of it because of its lengh :D

P.S. (2): I'm sorry if I did english mistakes, but I'm 13 and I'm learning it
at school_


Answer: Sorry if I didnt anwer before, I just had a LOT of work, but I found where my
problem comes. I want to have output of an Popen class in real time, so I do
some

    
    
    while True:
    a = proc.stdout.readlines() #proc is my Popen class, my problem...
    for line in a:
         srv.send(bytes(a)) #srv is a socket class that I configure, I prefer to dont add all of this shit here
    if self.stop == True:
        break
    

What I wanna do is that my readlines function blocks while proc gives an
output, but it just sucks up my CPU, and I cry

