@@ -32,7 +32,7 @@ def close(self):
32
32
in the same way
33
33
"""
34
34
if self ._handle is not None :
35
- win32pipe . DisconnectNamedPipe (self ._handle )
35
+ win32file . CloseHandle (self ._handle )
36
36
self ._handle = None
37
37
38
38
@@ -67,13 +67,10 @@ def open(self):
67
67
while conns < self ._max_conn_attempts :
68
68
try :
69
69
h = win32file .CreateFile (
70
- self ._pipe_name ,
71
- win32file .GENERIC_READ | win32file .GENERIC_WRITE ,
72
- 0 ,
73
- None ,
74
- win32file .OPEN_EXISTING ,
75
- win32file .FILE_FLAG_OVERLAPPED ,
76
- None )
70
+ self ._pipe_name ,
71
+ win32file .GENERIC_READ | win32file .GENERIC_WRITE , 0 , None ,
72
+ win32file .OPEN_EXISTING , win32file .FILE_FLAG_OVERLAPPED ,
73
+ None )
77
74
except pywintypes .error as e :
78
75
if e .winerror != winerror .ERROR_PIPE_BUSY :
79
76
raise TTransportException (
@@ -198,8 +195,8 @@ def create_named_pipe(self):
198
195
199
196
self ._handle = win32pipe .CreateNamedPipe (
200
197
self ._pipe_name , openMode , pipeMode ,
201
- win32pipe .PIPE_UNLIMITED_INSTANCES , self ._buff_size , self . _buff_size ,
202
- win32pipe .NMPWAIT_WAIT_FOREVER , saAttr )
198
+ win32pipe .PIPE_UNLIMITED_INSTANCES , self ._buff_size ,
199
+ self . _buff_size , win32pipe .NMPWAIT_WAIT_FOREVER , saAttr )
203
200
204
201
err = win32api .GetLastError ()
205
202
if self ._handle .handle == winerror .ERROR_INVALID_HANDLE :
@@ -223,3 +220,13 @@ def initiate_named_connect(self):
223
220
if ret == winerror .ERROR_PIPE_CONNECTED :
224
221
win32event .SetEvent (self ._overlapped .hEvent )
225
222
break
223
+
224
+ def close (self ):
225
+ """
226
+ The server must ensure to disconnect so that subsequent reconnect
227
+ attempts are successful
228
+ """
229
+ if self ._handle is not None :
230
+ win32pipe .DisconnectNamedPipe (self ._handle )
231
+ win32file .CloseHandle (self ._handle )
232
+ self ._handle = None
0 commit comments