-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Fix graceful exit #52080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return 0; | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to exit here, we just have to call $this->worker->stop()
and the command will finish gracefully once the handler is done.
$shouldHandle = $shouldForce || 'retry' === $io->choice('Please select an action', ['retry', 'delete'], 'retry'); | ||
$this->forceExit = true; | ||
try { | ||
$shouldHandle = $shouldForce || 'retry' === $io->choice('Please select an action', ['retry', 'delete'], 'retry'); | ||
} finally { | ||
$this->forceExit = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the messenger:failed:retry
it's a little different, the $io->choice()
method has an infinitive loop, so we need to exit if the command is waiting for an answer, otherwise we're stuck in the loop, which is the original issue that I tried to fix in #50787.
if ($this->shouldStop) { | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required because the worker is instantiated in loops as well.
@@ -180,7 +187,7 @@ private function runInteractive(string $failureTransportName, SymfonyStyle $io, | |||
} | |||
|
|||
// avoid success message if nothing was processed | |||
if (1 <= $count) { | |||
if (1 <= $count && !$this->shouldStop) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid printing the message if the command has been terminated.
Thank you @HypeMC. |
This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] Fix graceful exit with ids | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT One last case I missed in #52080 Commits ------- 1fc56bb [Messenger] Fix graceful exit with ids
My previous PR #50787 accidentally broke the behavior of the
messenger:consume
command. It no longer waits for the handler to finish, instead it exists immediately.