I need to implement non-blocking reading and writing from windows named pipes using Python (ctypes). I am able to achieve this if the pipe is opened in server mode. But I fail to do it when opening the pipe with client, using CreateFile.
ReadFile blocks, no matter that the pipe was created with PIPE_NOWAIT by the server process. I'm trying to use windll.kernel32.SetNamedPipeHandleState on the handle returned by windll.kernel32.CreateFileW, but get an error ERROR_ACCESS_DENIED
The description for SetNamedPipeHandleState says that it must have GENERIC_READ and FILE_WRITE_ATTRIBUTES access for a read-only pipe.
How do I set these flags when opening a file? And will it actually help to resolve my problem?