Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Support additional systems for UNIX domain sockets #58

Open
scfarley opened this issue Oct 16, 2019 · 2 comments
Open

Support additional systems for UNIX domain sockets #58

scfarley opened this issue Oct 16, 2019 · 2 comments

Comments

@scfarley
Copy link

With commit 5a20db1, UNIX domain sockets was introduced, yet it only supports Linux and MacOS (Darwin). Additional systems can easily be added. There are a few options, but I am not sure which is best. Here is what I am currently using:

diff --git a/pythonx/neovim_rpc_server.py b/pythonx/neovim_rpc_server.py
index d669fd0..055bbc0 100644
--- a/pythonx/neovim_rpc_server.py
+++ b/pythonx/neovim_rpc_server.py
@@ -296,7 +296,10 @@ class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
     pass
 
 
-if sys.platform in ['linux', 'darwin']:
+# if sys.platform in ['freebsd11', 'linux', 'darwin']:
+# if platform.system() in ['Darwin', 'DragonFly', 'FreeBSD', 'Linux', 'NetBSD',
+#                          'OpenBSD']:
+if os.name == 'posix':
     class ThreadedUnixServer(socketserver.ThreadingMixIn,
                              socketserver.UnixStreamServer):
         pass

The test for posix is the most broad, but I do not know if it would include any systems that cannot handle it. While sys.platform would work, it would grow fairly quickly since the BSD's all have the version of the OS appended to them. There is finally platform.system() which is basically uname -s which would work too and be easier than sys.platform.

Another alternative is to try defining the class and handle the exception. It should work everywhere:

diff --git a/pythonx/neovim_rpc_server.py b/pythonx/neovim_rpc_server.py
index d669fd0..ca278c6 100644
--- a/pythonx/neovim_rpc_server.py
+++ b/pythonx/neovim_rpc_server.py
@@ -296,12 +296,12 @@ class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
     pass
 
 
-if sys.platform in ['linux', 'darwin']:
+try:
     class ThreadedUnixServer(socketserver.ThreadingMixIn,
                              socketserver.UnixStreamServer):
         pass
     has_unix = True
-else:
+except:
     has_unix = False
@roxma
Copy link
Owner

roxma commented Oct 23, 2019

https://stackoverflow.com/questions/32612235/what-is-os-name-on-cygwin

Looks like os.name yields posix on cygwin, I'm not sure it's going to work

@scfarley
Copy link
Author

scfarley commented Nov 1, 2019

The code can check for posix but exclude cygwin. From what I have read, cygwin does have a form of UNIX domain sockets but cannot pass file descriptors using it.

However, what about trying to instantiate ThreadedUnixServer as the check? Does cygwin have it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants