Executing functions in parallel

前端 未结 6 1667
情歌与酒
情歌与酒 2020-12-16 18:55

I have a function that needs to go over around 20K rows from an array, and apply an external script to each. This is a slow process, as PHP is waiting for the script to be e

6条回答
  •  半阙折子戏
    2020-12-16 19:34

    Not sure if a solution for your situation but you can redirect the output of system calls to a file, thus PHP will not wait until the program is finished. Although this may result in overloading your server.

    http://www.php.net/manual/en/function.exec.php - If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

提交回复
热议问题