roxma / vim-hug-neovim-rpc

EXPERIMENTAL
MIT License
218 stars 28 forks source link

add ch_open option to avoid E906 on Windows #24

Closed notomo closed 6 years ago

notomo commented 6 years ago

By default, ch_open doesn't wait opening the channel. Under my environment(Windows 10, gvim), neovim_rpc#serveraddr gets E906: not an open channel error. This change solves the error.

Shougo commented 6 years ago

@roxma I think it should be merged. Can you merge it?

roxma commented 6 years ago

The default timeout seems to be 2s. It should be enough for program initialization. Why does it need inifinite timeout?

roxma commented 6 years ago

The main server should have already started at this line, If ch_open gets an error, It’s another issue

notomo commented 6 years ago

@roxma http://vim-jp.org/vimdoc-en/channel.html#waittime According to doc, "waittime" option doesn't wait by default. (2s is "timeout" option's default)

Thread already started when neovim_rpc_server.start() finished, but tcp server is not always ready. This pull-request is very simple solution. Maybe this is not the best solution.

roxma commented 6 years ago

hmm...

It seems the issue only happens on windows. If I add a delay before serve, it still works on my PC.

    def foo():
        import time
        time.sleep(1)
        _vim_server.serve_forever()

    # Start a thread with the server -- that thread will then start one
    # more thread for each request
    main_server_thread = threading.Thread(target=foo)
    clients_server_thread = threading.Thread(target=_nvim_server.serve_forever)
roxma commented 6 years ago

Thread already started when neovim_rpc_server.start() finished, but tcp server is not always ready.

According to the doc of winsock-listen, which is called when TCPServer is constructed, the system should have started queueing connection requests when ch_open is called.

I don't understand why it doesn't work on Windows.

notomo commented 6 years ago

https://github.com/notomo/tmp-appvoyer-test https://ci.appveyor.com/project/notomo/tmp-appvoyer-test/build/8

I made test repository and tested on appveyor Windows.(python2) I tested default waittime and infinite waittime, but the result was the same. The problem seems to be caused by my environment.

Thank you for your time.