$avp(async_attemps) = 1;
while($avp(async_attemps) < 4) { xlog("L_INFO", "------------- attemp $avp(async_attemps)\n"); $avp(async_attemps) = $avp(async_attemps) + 1; async_sleep("1"); xlog("L_INFO", "something\n"); }
xlog("L_INFO", "*** out of the while\n");
produces:
INFO: <script>: ------------- attemp 1 INFO: <script>: something INFO: <script>: *** out of the while
So, can async_sleep() be called within a while() block? IMHO it seems that the internal while counter lives in the initial process handling the request so when the processing is taken by other process (after async_sleep) it knows nothing about the while.
Thanks.
2011/8/4 Iñaki Baz Castillo ibc@aliax.net:
So, can async_sleep() be called within a while() block? IMHO it seems that the internal while counter lives in the initial process handling the request so when the processing is taken by other process (after async_sleep) it knows nothing about the while.
More issues:
route[ROUTE_TEST] { if($avp(async_attemps) == $null) $avp(async_attemps) = 0;
if($avp(async_attemps) < 3) { xlog("L_INFO", "------------- attemp $avp(async_attemps)\n"); $avp(async_attemps) = $avp(async_attemps) + 1; async_route("ROUTE_TEST", 3); }
xlog("L_INFO", "*********** if was false: attemp $avp(async_attemps)\n"); }
produces:
INFO: <script>: ------------- attemp 0 INFO: <script>: ------------- attemp 1
That's all.
It seems that calling async_route() in a route called by a previous async_route() call breaks thing.
Run it with higher debug level and maybe you get hints about what happens.
Cheers, Daniel
On 8/4/11 1:21 PM, Iñaki Baz Castillo wrote:
2011/8/4 Iñaki Baz Castilloibc@aliax.net:
So, can async_sleep() be called within a while() block? IMHO it seems that the internal while counter lives in the initial process handling the request so when the processing is taken by other process (after async_sleep) it knows nothing about the while.
More issues:
route[ROUTE_TEST] { if($avp(async_attemps) == $null) $avp(async_attemps) = 0;
if($avp(async_attemps)< 3) { xlog("L_INFO", "------------- attemp $avp(async_attemps)\n"); $avp(async_attemps) = $avp(async_attemps) + 1; async_route("ROUTE_TEST", 3); }
xlog("L_INFO", "*********** if was false: attemp $avp(async_attemps)\n"); }
produces:
INFO:<script>: ------------- attemp 0 INFO:<script>: ------------- attemp 1
That's all.
It seems that calling async_route() in a route called by a previous async_route() call breaks thing.
2011/8/4 Daniel-Constantin Mierla miconda@gmail.com:
Run it with higher debug level and maybe you get hints about what happens.
Ok, I'll do it.
Thanks.
Hello,
async_sleep() has some limitations listed in the readme, specifically, the state of config execution is lost since the resume happens in different application process. You better use the async_route() function if you are not that familiar with the internal cfg file interpreter. As a matter of fact, async_sleep() was added more for sampling reasons, to help other developers discover internal async API.
Cheers, Daniel
On 8/4/11 1:10 PM, Iñaki Baz Castillo wrote:
$avp(async_attemps) = 1;
while($avp(async_attemps)< 4) { xlog("L_INFO", "------------- attemp $avp(async_attemps)\n"); $avp(async_attemps) = $avp(async_attemps) + 1; async_sleep("1"); xlog("L_INFO", "something\n"); }
xlog("L_INFO", "*** out of the while\n");
produces:
INFO:<script>: ------------- attemp 1 INFO:<script>: something INFO:<script>: *** out of the while
So, can async_sleep() be called within a while() block? IMHO it seems that the internal while counter lives in the initial process handling the request so when the processing is taken by other process (after async_sleep) it knows nothing about the while.
Thanks.