On Saturday, 18 March 2017 at 16:15:30 UTC, ooyu wrote:
When i was uing parallel-foreach loop, got this error:
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
object.Error@(0): Access Violation
----------------
0x0056CCB8 in _flushbu
0x005663C7 in fwrite
0x0041D39F in nothrow @nogc @trusted uint
std.stdio.trustedFwrite!(char).trustedFwrite(shared(core.stdc.stdio._iobuf)*, const(char[]))
at C:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(3836)
0x004611AA in D3std6format99__T14formattedWri at
C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(556)
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
code is here:
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
foreach( web_url; parallel(urls) ){
try{
auto rq = Request(); // using dlang-requests library
auto d = rq.get( std.uri.encode(web_url) ); // file url
File f = File(path_hash[web_url], "wb");
f.write( d.responseBody );
f.close();
}
catch(std.exception.ErrnoException e){}
}
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
I don't understand why got Access Violation error. :-(
Hello,
Also don't understand the reason and I can't reproduce this
error. Can you try to pass ubyte[] to f.write() explicitly
converting responseBody to array? Like
f.write(d.responseBody.data());