Skip to content

Commit ffb92bd

Browse files
committed
fixed Issue #3 - windows pipe check for ok win_error
1 parent 2a7b4de commit ffb92bd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/namedpipe/_win32.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def wait(self):
134134

135135
# wait for the pipe to open (the other end to be opened) and return fileobj to read/write
136136
if win32pipe.ConnectNamedPipe(self._pipe, None):
137-
raise _win_error()
137+
code = win32api.GetLastError()
138+
if code != 535: # ERROR_PIPE_CONNECTED (ok, just indicating that the client has already connected)(Issue#3)
139+
raise _win_error(code)
138140

139141
# create new io stream object
140142
stream = Win32RawIO(self._pipe, self._rd, self._wr)
@@ -164,15 +166,15 @@ def __enter__(self):
164166
def __exit__(self, *_):
165167
self.close()
166168

167-
def readable(self)->bool:
168-
"""True if pipe's stream is readable"""
169+
def readable(self) -> bool:
170+
"""True if pipe's stream is readable"""
169171
return self._rd
170-
171-
def writable(self)->bool:
172-
"""True if pipe's stream is writable"""
172+
173+
def writable(self) -> bool:
174+
"""True if pipe's stream is writable"""
173175
return self._wr
174-
175-
176+
177+
176178
class Win32RawIO(io.RawIOBase):
177179
"""Raw I/O stream layer over open Windows pipe handle.
178180

0 commit comments

Comments
 (0)