diff --git a/src/Db.php b/src/Db.php index 50a2d5f..b6a70bf 100644 --- a/src/Db.php +++ b/src/Db.php @@ -164,6 +164,7 @@ public function process(callable $worker, $delay = 1, $limit = null, $timeout = 'failure' => 0, 'skipped' => 0, ]; + while ($processed++ < $limit && ($job = $this->reserve($timeout, $delay))) { $result = $worker($job->getBody(), $job); if ($result) { @@ -176,6 +177,9 @@ public function process(callable $worker, $delay = 1, $limit = null, $timeout = $job->bury(); ++$stats['failure']; } + if ($this->connection->isUnderTransaction()) { + $this->connection->commit(); + } } return $stats;