Open chwpearse opened 1 year ago
Three tips:
read_output()
instead of read_output_lines()
.read_output()
can always return less output than requested.$poll_io()
before reading, even if you call it with no waiting time: $poll_io(0)
.Ah thanks for that. For anyone who hits this problem in the future here's what I did:
proc_read_long_singleline <- function(proc, wait = 100, timeout = 5000){
my_proc$poll_io(wait)
counter <- 1
output_lines_res <- proc$read_output_lines(1)
output_res <- c()
while(length(output_lines_res) == 0 & counter*wait <= timeout){
output_res <- proc$read_output() %>% append(output_res, .)
proc$poll_io(wait)
counter <- counter + 1
output_lines_res <- proc$read_output_lines(1) %>% append(output_lines_res, .)
}
res_output <- paste0(output_res, collapse = '') %>% paste0(output_lines_res)
}
if(exists('my_proc')){my_proc$kill()}
my_proc <- process$new(cmd_file, stdin = '|', stdout = '|', stderr = '|')
my_proc$write_input('\n')
read_chars <- my_proc %>% proc_read_long_singleline()
I think this is documented, but I'll keep this issue open until we improve the documentation.
When running a process I seem to unable to read more than 78643 chars.
If I use read_output_lines() I get no result and when I use read_output() it only reads the first 78,643 chars. I think read_output_lines() is not reaching the \n at the end of the line so it doesn't return anything.
After reading with read_output() I cannot read the rest of the line until I send new input. I have tried to troubleshoot with the R debugger but as the read happens through the dll file I can't see what's happening.
The below creates and runs a cmd file to write 100,000 chars, but processx only reads 78,643. It then does the same for 50,000 chars and it reads all 50,000 and prints a summary at the end.
This is on Windows 10 & 11
Created on 2023-05-27 with reprex v2.0.2
Standard output and standard error
``` sh -- nothing to show -- ```