On 08/22, Bram Moolenaar wrote:

ch_sendraw seems to fail when sending large chunks of data to a job
started in non-blocking mode.  Is this expected?

Steps to reproduce:

- Copy the following into a file, and source it from vim

let args = ['cat']
let opts = {
        \ 'noblock': 1
        \}

let job = job_start(args, opts)
let data = repeat('X', 65537)

call ch_sendraw(job, data)
call ch_close_in(job)

Expected behavior:

- Nothing much (i.e. no errors)

Actual bevarior:

- E630: channel_write_input(): write while not connected

If on the other hand, I initialized data with 65536 bytes instead of
65537, then no error would be thrown.

You are using "noblock", which means the write may happen a bit later,
but then you use ch_close_in(), closing the channel before all the
writes are done.  If you put a sleep there it works.

Oh, I thought ch_close_in() would wait for any pending write to complete, but I guess that _special mode_ on `:help channel-close-in` did refer to non blocking channels in the end, didn't it?! My bad!

Then the next question is, how could I wait for any pending write operation to complete before calling ch_close_in()? Should I include a EOF in the last message, instead of calling ch_close_in()?

--
Matteo Landi
https://matteolandi.net

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20190822185421.GA73271%40hairstyle.local.

Raspunde prin e-mail lui