Comments (3)
Three tips:
- if you know that you can have long lines, you need to use
read_output()
instead ofread_output_lines()
. read_output()
can always return less output than requested.- you need to call
$poll_io()
before reading, even if you call it with no waiting time:$poll_io(0)
.
from processx.
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()
from processx.
I think this is documented, but I'll keep this issue open until we improve the documentation.
from processx.
Related Issues (20)
- Test failure on 10.6.8: Error ('test-ps-methods.R:18'): ps methods HOT 2
- Document common options for output encoding of Windows tools HOT 2
- User-defined process name HOT 2
- Different behaviour inside and outside functions HOT 5
- `$call` should be a call or `NULL` in error objects HOT 3
- Release processx 3.8.1
- Release processx 3.9.0 HOT 1
- get_pid() different from Sys.getpid() on Windows HOT 2
- Compiler error during install: -fPIE HOT 7
- Release processx 3.8.2
- arguments with special character like \'~\' case an error. HOT 2
- Process hangs when using pipes with `stdout`, `stderr` for `latexmk -pdf` compilation HOT 2
- Move httpbin to test-poll-curl.R? HOT 2
- Upkeep for processx (2022)
- Use cli errors or file an issue if you don't have time to do it now
- `usethis::use_standalone("r-lib/rlang", "types-check")` instead of home grown argument checkers;
- Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples
- processx update from CRAN HOT 3
- Installation from CRAN failed on Fedora 30 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from processx.