RejectedSoftware Forums

Sign up

serious async problem

I ran the test program from the api docs in 0.8.0-beta.4.
https://vibed.org/api/vibe.core.concurrency/async

auto val = async({
		logInfo("Starting to compute value in worker task.");
		sleep(500.msecs); // simulate some lengthy computation
		logInfo("Finished computing value in worker task.");
		return 32;
	});

	logInfo("Starting computation in main task");
	sleep(200.msecs); // simulate some lengthy computation
	logInfo("Finished computation in main task. Waiting for async value.");
	logInfo("Result: %s", val.getResult());

Here's the result.

Starting computation in main task
Starting to compute value in worker task.
Finished computation in main task. Waiting for async value.
CoreTaskFiber was terminated unexpectedly: Joining tasks in foreign threads is currently not supported.
Program exited with code 255

Any chance this could get fixed? I was seriously relying on this feature working; it was mentioned the introductory book as working, and the online docs don't indicate a difficultly, so I incorrectly thought async was working.

Re: serious async problem

Am 17.03.2017 um 18:21 schrieb Carl Sturtivant:

I ran the test program from the api docs in 0.8.0-beta.4.
https://vibed.org/api/vibe.core.concurrency/async

auto val = async({
		logInfo("Starting to compute value in worker task.");
		sleep(500.msecs); // simulate some lengthy computation
		logInfo("Finished computing value in worker task.");
		return 32;
	});

	logInfo("Starting computation in main task");
	sleep(200.msecs); // simulate some lengthy computation
	logInfo("Finished computation in main task. Waiting for async value.");
	logInfo("Result: %s", val.getResult());

Here's the result.

Starting computation in main task
Starting to compute value in worker task.
Finished computation in main task. Waiting for async value.
CoreTaskFiber was terminated unexpectedly: Joining tasks in foreign threads is currently not supported.
Program exited with code 255

Any chance this could get fixed? I was seriously relying on this feature working; it was mentioned the introductory book as working, and the online docs don't indicate a difficultly, so I incorrectly thought async was working.

This should be fixed/implemented for the new vibe-core package, which
is not yet the default in 0.8.0. Try adding this to the package recipe
to force using vibe-core:

dependency "vibe-d:core" version="~>0.8.0-beta"
subConfiguration "vibe-d:core" "vibe-core"

Re: serious async problem

On Fri, 17 Mar 2017 21:09:12 +0100, Sönke Ludwig wrote:

Starting computation in main task
Starting to compute value in worker task.
Finished computation in main task. Waiting for async value.
CoreTaskFiber was terminated unexpectedly: Joining tasks in foreign threads is currently not supported.
Program exited with code 255

Any chance this could get fixed? I was seriously relying on this feature working; it was mentioned the introductory book as working, and the online docs don't indicate a difficultly, so I incorrectly thought async was working.

This should be fixed/implemented for the new vibe-core package, which
is not yet the default in 0.8.0. Try adding this to the package recipe
to force using vibe-core:

dependency "vibe-d:core" version="~>0.8.0-beta"
subConfiguration "vibe-d:core" "vibe-core"

I tried this, paranoiacally ran dub upgrade and dub --force and got the same error.

Re: serious async problem

On Fri, 17 Mar 2017 21:10:18 GMT, Carl Sturtivant wrote:

On Fri, 17 Mar 2017 21:09:12 +0100, Sönke Ludwig wrote:

Starting computation in main task
Starting to compute value in worker task.
Finished computation in main task. Waiting for async value.
CoreTaskFiber was terminated unexpectedly: Joining tasks in foreign threads is currently not supported.
Program exited with code 255

Any chance this could get fixed? I was seriously relying on this feature working; it was mentioned the introductory book as working, and the online docs don't indicate a difficultly, so I incorrectly thought async was working.

This should be fixed/implemented for the new vibe-core package, which
is not yet the default in 0.8.0. Try adding this to the package recipe
to force using vibe-core:

dependency "vibe-d:core" version="~>0.8.0-beta"
subConfiguration "vibe-d:core" "vibe-core"

I tried this, paranoiacally ran dub upgrade and dub --force and got the same error.

Apologies, not so, I didn't have the configuration exactly right. Now it doesn't do that. It runs and does not terminate with an error, just hangs. After 10 seconds I hit ^C. When I attempted to rerun via dub it could not listen on the same port. Here's the output.

[vibe-0(M3JX) INF] Starting to compute value in worker task.
[main(nDQ8) INF] Starting computation in main task
[main(nDQ8) INF] Finished computation in main task. Waiting for async value.
^C
carl@carl1604:~/Documents/vibed/asynctest$ [main(nDQ8) INF] [main(----) INF] Received signal 2. Shutting down.

I'll try running it again.

Re: serious async problem

On Fri, 17 Mar 2017 21:09:12 +0100, Sönke Ludwig wrote:

This should be fixed/implemented for the new vibe-core package, which
is not yet the default in 0.8.0. Try adding this to the package recipe
to force using vibe-core:

dependency "vibe-d:core" version="~>0.8.0-beta"
subConfiguration "vibe-d:core" "vibe-core"

OK, I modified the example to find out what was going on, because with this configuration it's hanging. Here's my code.

import vibe.core.core;
import vibe.core.log;

void busywait(long msecs) {
    import std.datetime;
    StopWatch sw;
    sw.start();
    ulong i;
    logInfo("start waiting");
    while( sw.peek().msecs < msecs) {
        if( i%10000 == 0 ) logInfo("running %s msecs", sw.peek().msecs);
        ++i;
    }
    logInfo("done waiting");
}

void test()
{
    auto val = async({
        logInfo("Starting to compute value in worker task.");
//sleep(500.msecs); // simulate some lengthy computation
        	busywait(500);
		logInfo("Finished computing value in worker task.");
		return 32;
	});

	logInfo("Starting computation in main task");
	sleep(200.msecs); // simulate some lengthy computation
	logInfo("Finished computation in main task. Waiting for async value.");
	logInfo("Result: %s", val.getResult());
}

The log output never got as far as "Finished computing value in worker task." and the busywait call's output stopped after 203 msecs. So it seems the call of getResult causes the asynchronous task to hang.

Re: serious async problem

As a sanity check I reran the above on a different machine, with the latest beta including the latest new core, and got the following output. The ^C is after waiting for 10 seconds.

Running ./asynctest 
[main(----) INF] Listening for requests on http://127.0.0.1:8080/
[main(----) INF] Please open http://127.0.0.1:8080/ in your browser.
[vibe-0(OLhj) INF] Starting to compute value in worker task.
[vibe-0(OLhj) INF] start waiting
[vibe-0(OLhj) INF] running 0
[main(WqEv) INF] Starting computation in main task
[vibe-0(OLhj) INF] running 3
[vibe-0(OLhj) INF] running 4
[vibe-0(OLhj) INF] running 7
[vibe-0(OLhj) INF] running 8
[vibe-0(OLhj) INF] running 10
[vibe-0(OLhj) INF] running 11
[vibe-0(OLhj) INF] running 14
   .
   .
   .
[vibe-0(OLhj) INF] running 191
[vibe-0(OLhj) INF] running 193
[vibe-0(OLhj) INF] running 195
[vibe-0(OLhj) INF] running 196
[vibe-0(OLhj) INF] running 198
[vibe-0(OLhj) INF] running 200
[main(WqEv) INF] Finished computation in main task. Waiting for async value.
^C[main(WqEv) INF] [main(----) INF] Received signal 2. Shutting down.

carl@carl1604:~/Documents/vibed/asynctest$ fuser 8080/tcp
8080/tcp:             5063
carl@carl1604:~/Documents/vibed/asynctest$ kill 5063
[main(----) INF] Received signal 15. Shutting down.
carl@carl1604:~/Documents/vibed/asynctest$ fuser 8080/tcp
8080/tcp:             5063

The 200.msecs computation in the main task completes, calls getResult on the worker task, which promptly hangs, not continuing printing out its execution times until 500.msecs and terminating with the log message "Finished computing value in worker task.". The resulting hung process cannot be terminated by ordinary means.