Python Subprocess Readline Hangs() After Reading All Input
I am trying to readlines from the tcp server that I ran in the same script. I am able to send one command and reads its output but at the end (after reading all outputs) it looks l
Solution 1:
readline
hangs because your TCP connection is still open and readline
expects more data to come in. You must close the connection from server side to notify readline
that there is nothing more to read. Usually it is done by closing socket on client side notifying the server that there will not be any more requests to it. When server finishes processing all your commands it closes socket too. And this is the signal for you that you have received all the data that server sent to you.
Or, alternatively, if you don't want to close the connection, you must invent delimiters which will mark end of response. So the client will stop calling readline
when such delimiter is read.
Post a Comment for "Python Subprocess Readline Hangs() After Reading All Input"