Search code examples
pywin32

Can't use win32 named pipes: win32file.SetFilePointer fails on Linux Proton


I have a program using Named Pipes to communicate with another process, but it fails in a user's computer when they're running Linux Proton emulating windows instead of native Windows. "Proton" is what Steam Deck devices uses to play Windows games. There is "Proton" and "Proton GE" and this fails in both cases.

import win32pipe, win32file

pipe = win32pipe.CreateNamedPipe(
r'\\.\pipe\\'+'my_pipe',
win32pipe.PIPE_ACCESS_DUPLEX, win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_WAIT,
1, 65536, 65536, 0, None)

win32file.SetFilePointer(pipe, 0, win32file.FILE_BEGIN)
  • No error in regular Windows.

  • Error in Linux "Proton" running Windows: pywintypes.error: (66, 'SetFilePointer', 'Bad device type.')

Any workaround for this? Or do I just have to abandon named pipes entirely when developing for users to use Proton? I was thinking about having it write to a file on disk instead of using named pipes and then polling that file, but that would be a last resort...


Solution

  • This is a bug in Linux Proton and doesn't look like it will be fixed any time soon.

    The workaround was thus: Have the python program put the SetFilePointer in a try/except block. If it fails, fall back to a different protocol (an http protocol) and don't try to use named pipes.