Skip to content

Commit 4898c7c

Browse files
committed
Zero-length buffers and no exception on ERROR_BROKEN_PIPE
1 parent 93f4577 commit 4898c7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/namedpipe/_win32.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
# TODO: assess options: PIPE_WAIT, PIPE_NOWAIT, PIPE_ACCEPT_REMOTE_CLIENTS, PIPE_REJECT_REMOTE_CLIENTS
103103

104104
max_instances = _wt(1) # PIPE_UNLIMITED_INSTANCES returns 'invalid params'. Pipes are point-to-point anyway
105-
buffer_size = _wt(65536) # in all examples online provide 64KB buffer. 0 doesn't fail CreateNamedPipeW, but maybe performance better?
105+
buffer_size = _wt(0)
106106
timeout = _wt(0)
107107

108108
# "open" named pipe
@@ -243,7 +243,10 @@ def readinto(self, b: WritableBuffer) -> Union[int, None]:
243243
success = self.kernel32.ReadFile(self.handle, buf, size, ctypes.byref(nread), None)
244244
if not success:
245245
code = ctypes.get_last_error()
246-
if code not in (ERROR_MORE_DATA, ERROR_IO_PENDING):
246+
# ERROR_MORE_DATA - not big deal, will read next time
247+
# ERROR_IO_PENDING - should not happen, unless use OVERLAPPING, which we don't so far
248+
# ERROR_BROKEN_PIPE - pipe was closed from other end. While it is an error, test seemingly expects to receive 0 instead of exception
249+
if code not in (ERROR_MORE_DATA, ERROR_IO_PENDING, ERROR_BROKEN_PIPE):
247250
raise _win_error(code)
248251

249252
return nread.value

0 commit comments

Comments
 (0)