Answer the question
In order to leave comments, you need to log in
How to run many tasks at once on gearman in parallel in php?
Actually, I use the construction of adding tasks like this:
$jobs = DB::select()
->from('jobs')
->where('status', '=', 'wait')
->and_where('active', '=', 1)
->execute()
->as_array();
foreach($jobs as $job)
{
$update = DB::update('jobs')
->set(array('status' => 'process'))
->where('id', '=', $job['id'])
->execute();
$client = new GearmanClient();
# Подключаемся к серверу Gearman
$client->addServer();
# Шлем сообщение
$client->doBackground('Task', json_encode($job));
sleep(1);
}
$worker->addServer();
$worker->addFunction('TaskSpam', array($this, "Task"));
while (1) {
$ret = $worker->work();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question