Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to flush output from a Shelter? #412

Closed
christianp opened this issue Apr 17, 2024 · 5 comments · Fixed by #419
Closed

Is it possible to flush output from a Shelter? #412

christianp opened this issue Apr 17, 2024 · 5 comments · Fixed by #419
Labels
bug Something isn't working
Milestone

Comments

@christianp
Copy link

I use Shelter.captureR calls to evaluate code. It seems that the output is a list of all completed lines in the process's output. If I output some text that doesn't end in a newline, for example cat("hey"), it's not included in the output.

I couldn't see a method to flush the output, or an option for captureR. Is there one?

@georgestagg
Copy link
Member

I couldn't see a method to flush the output, or an option for captureR. Is there one?

There is not, sorry. See the discussions at #375 and emscripten-core/emscripten#2770 (comment) for more details.

I think right now the best you can do is append something like cat(fill=TRUE) to the end of any R code you want to evaluate. However, I don't particularly like solutions like that because they add an additional empty output line if the preceding code already printed a final newline.

If there is truly no better alternative with Emscripten, and you think it would be useful, we could possibly add an option to captureR to print the final newline at the C level and then strip the extra empty line from the results array if it appears.

@georgestagg georgestagg added the bug Something isn't working label Apr 17, 2024
@christianp
Copy link
Author

An option to print a newline and strip it if the last line is empty would solve this for me, I think.

@georgestagg
Copy link
Member

georgestagg commented Apr 17, 2024

Thinking about this some more, #375 was about the console experience rather than capturing output.

The fact that the final output line is not captured at all when using captureR should probably be considered a bug. So, I've tagged this as such and will try to get some kind of solution in place for the next version.

@christianp
Copy link
Author

Thanks, George!

@georgestagg
Copy link
Member

georgestagg commented Apr 24, 2024

No worries, I'll tag a release soon so that you can pin to v0.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants