Zulip Chat Archive
Stream: general
Topic: Any reason why reading stdout should fail?
Daniel Donnelly (Dec 05 2019 at 02:40):
elif self.state == self.AwaitingResponse: for line in self._proc.stdout: self.check_pause() json = JSON.loads(line) self.receive_queue.append(json) self.state = self.ProcessingResponse
This grabs the first few lines but on the last line the thread the above is running in crashes because of the read of stdout. No error is presented in my debugger.
I'm connecting the process like this:
def connect_to_server(self): exec = self.lean_executable self._proc = subprocess.Popen([exec, "-j0", "--server"], stdin =subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, bufsize=1, env={'LEAN_PATH': self.lean_folder}) self.state = self.ServerRunning
Also doing stdout.readlines()
will crash the process as well as stdout.read()
or stdout.readline()
'ing to the end.
Daniel Donnelly (Dec 05 2019 at 02:58):
The solution is to use communicate()
:
stdout, stderr = self._proc.communicate() print(stdout)
Process doesn't crash when you do that.
Last updated: Dec 20 2023 at 11:08 UTC