I encountered misleading errors, specifically Error 232 ('Pipe being closed'). However, the actual reason for this error is that there is nothing to read. My expectation is to update Error 232 to have a more appropriate name. Alternatively, adding a new error, let's say, 'XXX: Nothing to read,' would be helpful.
(result_status, data) = win32file.ReadFile(self.pipe, self.buffer_read)
# Check if the read was successful
if result_status == 0:
# Decode the received data
received_packet = self.pkg_decode(data.decode('utf-8'))
return received_packet
except Exception as e:
print(e) # Updated error message -> (232, 'ReadFile', 'The pipe is being closed.')
return None
"I recently made my first attempt with the Python pipe. It worked well as long as I used:
win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_WAIT
However, when I switched to:
win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_NOWAIT
I encountered misleading errors, specifically Error 232 ('Pipe being closed'). However, the actual reason for this error is that there is nothing to read. My expectation is to update Error 232 to have a more appropriate name. Alternatively, adding a new error, let's say, 'XXX: Nothing to read,' would be helpful.
Here is a snippet of my class:
python
def create_pipe(self): return win32pipe.CreateNamedPipe( r'\.\pipe\mypipe', win32pipe.PIPE_ACCESS_DUPLEX, win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_NOWAIT, #PIPE_WAIT 1, 65536, 65536, 0, None)
def get_message(self) -> Dict: try:
Read data from the pipe
Pywin32, Version 306
There is even a report on stackoverflow: https://stackoverflow.com/questions/19636548/named-pipe-232-the-pipe-is-being-closed