Under Windows 7 I have a Python 3 application which communicates via named pipe with an executable, written in C using Visual Studio. Within Python I'm using win32pipe package.
I observe that within the executable reading from pipe is blocking:
readResult = ReadFile(plafParams->hrpipe_p, &byte, 1, &dwBytesTransferred, &overlap);
The pipe is opened with:
...
...
overlap.hEvent = NULL;
overlap.Offset = 0;
overlap.OffsetHigh = 0;
overlap.Pointer = NULL;
...
...
plafParams->hwpipe_p = CreateFile(pipeName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, &overlap);
overlap
is a static global variable and initialized as above.
OVERLAPPED overlap;
In Python the pipe is opened like:
self._rpipe = win32pipe.CreateNamedPipe(r'\\.\pipe\wskr_%s'%(self._comport,), win32pipe.PIPE_ACCESS_DUPLEX | win32file.FILE_FLAG_OVERLAPPED , 0, 1, 256, 256, 0, None)
After waiting for connection to the pipe, I write to it like
win32file.WriteFile(self._rpipe, bytes)
It works, and I get the sent bytes in the executable without problems, but I would like to have a non-blocking read. Therefore I opened the pipe with win32file.FILE_FLAG_OVERLAPPED
, but that doesn't help...
I would appreciate any hint ;-)