spatie / async

Easily run code asynchronously

Home Page:https://spatie.be/en/opensource/php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pool->wait() non blocking

tomoliveirabastos opened this issue · comments

is possible to do an function like waitNonBlockIo to continue execute the script and run a Pool in background ?

plus one for this functionality

I have the same question! if this do not exists, this is not async. also has poor docs.

There is one big thing most seems to overlook when using this package.
You can't really run the wait method directly, it's an example you should adapt to.
You must create a similar function that you continuously call/check within your own setup.

The while loop does not know of any other scripts running it can check on, so it blocks by design, only stops when all Pools are done.

Your program need a custom loop routine then add a call to something like:

  public function checkPool()
  {
    if ($this->inProgress) {
      foreach ($this->inProgress as $process) {
        if ($process->getCurrentExecutionTime() > $this->timeout) {
          $this->markAsTimedOut($process);
        }

        if ($process instanceof SynchronousProcess) {
          $this->markAsFinished($process);
        }
      }
    }
  }

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.