Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d0a08b

Browse files
committed
feature#43576 [Messenger] subtract handling time from sleep time in worker (nicolas-grekas)
This PR was merged into the 5.4 branch.Discussion----------[Messenger] subtract handling time from sleep time in worker| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -Commits-------da79946 [Messenger] subtract handling time from sleep time in worker
2 parents2422466 +da79946 commit2d0a08b

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
@@ -87,6 +87,7 @@ public function run(array $options = []): void
8787

8888
while (false ===$this->shouldStop) {
8989
$envelopeHandled =false;
90+
$envelopeHandledStart =microtime(true);
9091
foreach ($this->receiversas$transportName =>$receiver) {
9192
if ($queueNames) {
9293
$envelopes =$receiver->getFromQueues($queueNames);
@@ -113,10 +114,12 @@ public function run(array $options = []): void
113114
}
114115
}
115116

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp