vibed - Executing std.process synchronously from vibe.d sometimes silently hangs the server -
i wrote vibe.d web-ui clang-format, when presented this input while using llvm style, server hangs.
the code handling post:
void post(string style, string code) { import std.algorithm; import std.file; import std.conv; import std.process; auto pipes = pipeprocess(["clang-format", "-style="~style], redirect.stdout | redirect.stdin); scope(exit) wait(pipes.pid); pipes.stdin.write(code); pipes.stdin.close; pipes.pid.wait; code = pipes.stdout.byline.joiner.to!string; string selectedstyle = style; render!("index.dt", styles, code, selectedstyle); } this shouldn't done in blocking way, @ loss how asynchronously. have tried wrapping contents of function in runtask, couldn't figure out way call correctly.
how can make reliable?
you writing data program's stdin without reading stdout. since pipe buffer size limited, causes executed program block on writing stdout, in turn causes program block on writing stdin.
the solution read data writing it. simple way create second thread reads data, while main thread writes it.
Comments
Post a Comment