Ich schrieb eine vibe.d
Web-UI für clang-format
, wenn mit this input bei Verwendung LLVM-Stil präsentiert wird, hängt der Server.Ausführen von std.process synchron von vibe.d manchmal hängt manchmal den Server
Der Code für POST Handhabung:
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);
}
Dies ist wahrscheinlich nicht in einer blockierenden Art und Weise getan werden soll, aber ich bin ratlos, wie es asynchron zu tun. Ich habe versucht, den Inhalt der Funktion in runTask
zu wickeln, aber ich konnte nicht herausfinden, wie man es richtig aufruft.
Wie kann ich es zuverlässig machen?