RejectedSoftware Forums

Sign up

Trying to use PipedProcess with vibe.d - compilation failures

I'm attempting to use https://gist.github.com/s-ludwig/8434299
It requires stdfilestream, I got it from there: https://gist.github.com/s-ludwig/5942882

After adding the necessary imports (my current efforts) I'm left with the following error:

source/stdfilestream.d(41,72): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(46,20): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(52,20): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(64,20): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(70,13): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(76,14): Error: no property 'writer' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'write'?
source/stdfilestream.d(82,14): Error: no property 'writer' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'write'?
source/stdfilestream.d(90,14): Error: no property 'writer' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'write'?
source/stdfilestream.d(108,15): Error: no property 'writer' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'write'?
source/stdfilestream.d(115,15): Error: no property 'writer' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'write'?
source/stdfilestream.d(135,40): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(136,43): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?
source/stdfilestream.d(138,16): Error: no property 'reader' for type 'vibe.stream.taskpipe.TaskPipe', did you mean 'read'?

I could replace every writer.write with just write in that file, but what about m_readPipe.reader.empty;? Does this even make sense right now? I'm clueless.

Re: Trying to use PipedProcess with vibe.d - compilation failures

On Thu, 15 Oct 2015 10:51:19 GMT, krzaq wrote:

I'm attempting to use https://gist.github.com/s-ludwig/8434299
It requires stdfilestream, I got it from there: https://gist.github.com/s-ludwig/5942882

After adding the necessary imports (my current efforts) I'm left with the following error:

(...)

I could replace every writer.write with just write in that file, but what about m_readPipe.reader.empty;? Does this even make sense right now? I'm clueless.

StdFileStream is now part of vibe.d: http://vibed.org/api/vibe.stream.stdio/StdFileStream

I'm not 100% sure if this is fully compatible with the PipedProcess implementation, but I guess so, because I haven't changed anything in that area for quite a while.

Re: Trying to use PipedProcess with vibe.d - compilation failures

On Thu, 15 Oct 2015 11:18:52 GMT, Sönke Ludwig wrote:

StdFileStream is now part of vibe.d: http://vibed.org/api/vibe.stream.stdio/StdFileStream

I'm not 100% sure if this is fully compatible with the PipedProcess implementation, but I guess so, because I haven't changed anything in that area for quite a while.

Okay, it seems to compile, but now my code hangs and I'm not sure what to do about it:

PipedProcess p = new PipedProcess("clang-format", ["-style="~style]);

p.stdin.write(code);

code = "";

for(ulong toRead = 0; toRead > 0 || p.stdout.connected; toRead = p.stdout.leastSize){
	ubyte[] buf = new ubyte[toRead];
	p.stdout.read(buf);
	code ~= buf;
}

My previous code: (unfortunately, it caused the whole app to hang sometimes)

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;

Re: Trying to use PipedProcess with vibe.d - compilation failures

Okay, I got it to work by adding p.stdin.finalize; after all the data was passed to the stdin. Thanks for the help!

Re: Trying to use PipedProcess with vibe.d - compilation failures

Am 15.10.2015 um 14:13 schrieb krzaq:

PipedProcess p = new PipedProcess("clang-format", ["-style="~style]);

p.stdin.write(code);

code = "";

for(ulong toRead = 0; toRead > 0 || p.stdout.connected; toRead = p.stdout.leastSize){
	ubyte[] buf = new ubyte[toRead];
	p.stdout.read(buf);
	code ~= buf;
}

Side note: you can also use vibe.stream.operations.readAll or
readAllUTF8 to replace the explicit read loop.

Re: Trying to use PipedProcess with vibe.d - compilation failures

On Thu, 15 Oct 2015 17:23:45 +0200, Sönke Ludwig wrote:

Side note: you can also use vibe.stream.operations.readAll or
readAllUTF8 to replace the explicit read loop.

Awesome. I checked the documentation but it's not mentioned there and there are no examples, so I did the explicit read loop by feel.

It works and is now pleasasant to look at, thanks!

Re: Trying to use PipedProcess with vibe.d - compilation failures

On Thu, 15 Oct 2015 18:23:32 GMT, krzaq wrote:

On Thu, 15 Oct 2015 17:23:45 +0200, Sönke Ludwig wrote:

Side note: you can also use vibe.stream.operations.readAll or
readAllUTF8 to replace the explicit read loop.

Awesome. I checked the documentation but it's not mentioned there and there are no examples, so I did the explicit read loop by feel.

It works and is now pleasasant to look at, thanks!

Good point, I've now mentioned this in the vibe.core.stream module: 3f6c615.