In a nutshell . I want to have a common timeout for a call runTasks()in the Gearman client.
It seems to me that I cannot be the first to want this, but I cannot find an example of how to assemble it.
Here is what I want to achieve:
- In a PHP script, use the Gearman client to run multiple episodes in parallel.
- Each task will produce some search results that the PHP script will need to process.
- Some of the tasks may take some time, but I do not want to wait for the slowest. Instead, after N milliseconds, I want to process the results from all completed tasks and interrupt or ignore those that did not.
Requirements 1 and 2 are quite simple using PHP GearmanClient addTask () and runTasks () , but this is blocked until all provided tasks are completed, therefore it does not meet requirements 3.
Here are a few approaches I've tried so far:
- The timeout with setTimeout () measures the connection idle time, which is not of interest to me.
- Using background jobs or tasks is not possible to retrieve data returned to workers. There are several questions that already cover this: 1 2
- addTaskStatus() - , , , . " ", , .
- GEARMAN_CLIENT_NON_BLOCKING, , ,
runTasks() setTaskBackground() setTask().
, , , , , Gearman RabbitMQ.