Skip to content

Commit 3b9457e

Browse files
[Messenger] subtract event handling time from sleep time in worker
1 parent 732acf5 commit 3b9457e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Symfony/Component/Messenger/Worker.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ public function run(array $options = []): void
113113
}
114114
}
115115

116-
if (false === $envelopeHandled) {
116+
if (!$envelopeHandled) {
117+
$start = microtime(true);
117118
$this->dispatchEvent(new WorkerRunningEvent($this, true));
118119

119-
usleep($options['sleep']);
120+
if (0 < $sleep = (int) ($options['sleep'] - 1e6 * (microtime(true) - $start))) {
121+
usleep((int) $sleep);
122+
}
120123
}
121124
}
122125

0 commit comments

Comments
 (0)