0

I have a laravel application in which run I'm running a command line task.

The task basically fetches data from the database and writes it to disk. The files are about 15-35kb in size. There are about 30 to 60 files being written for each task. Currently I'm testing running just one task.

 public function run(){
    // ...code....
    $awaitables = [];
    foreach ($sites as $site){
        try {
            $awaitables[] = $this->process($site);
        } catch(\Exception $e){
            \Log::exception($e);
        }
    }
    $asyncCalls = \HH\Asio\v($awaitables);
    echo "Im here". PHP_EOL;
    $returns = \HH\Asio\join($asyncCalls);
    var_dump($returns);
}

When I run the task time hhvm -v Eval.Jit=0 artisan exportfiles The time output shows around 2 minutes. However the files are created rather quickly within about 20 seconds or so. I'm wondering why is there a 1 minute hang after I see the dump of the $returns variable.

I thought HH\Asio\Join($awaitables); concludes the asynchronous processes.

HipHop VM 3.18.0-dev (rel)
Compiler: heads/master-0-g0f6803df27b27f929f5edc175e11d302643f3a2c
Repo schema: 1733dfccb8791a77b6ce7b894ddd66e3238c2106
set_mempolicy: Operation not permitted

Running MacBook Pro 16gb Sierra Using Docker For Mac

billf
  • 112
  • 9
user2108258
  • 803
  • 3
  • 13
  • 20
  • 1
    If the files are created and the method finishes, it doesn't sound like an async issue to me. Could you share the `process` method code? – concat Apr 28 '17 at 13:05
  • I'm not convinced it has anything to do with the async code. You say: `1 minute hang after I see the dump of the $returns variable` since `var_dump($returns)` happens entirely after anything async-related, you know that the async code has already finished and that's not where time is being spent. Perhaps it is code that runs after this method finishes. – billf Apr 28 '17 at 17:25
  • Nothing runs after the run method. Laravel tasks will execute the run method only unless otherwise specified. – user2108258 Apr 28 '17 at 19:18
  • Once all the `Awaitable`s are `join`ed, the call blocks like any other non-async function. If you were wondering, unfinished `Awaitable`s that aren't `join`ed are simply thrown out when the script ends; they don't block the script from finishing. Check if the script reaches the end before the hang. – concat Apr 29 '17 at 15:16

0 Answers0