Skip to content
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

[Messenger] Fix graceful exit #52080

Merged
merged 1 commit into from
Oct 16, 2023
Merged

[Messenger] Fix graceful exit #52080

merged 1 commit into from
Oct 16, 2023

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Oct 16, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #52077
License MIT

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.

return 0;
return false;
Copy link
Contributor Author

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.

Comment on lines -201 to +213
$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;
}
Copy link
Contributor Author

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.

Comment on lines +162 to +164
if ($this->shouldStop) {
break;
}
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

@fabpot
Copy link
Member

fabpot commented Oct 16, 2023

Thank you @HypeMC.

@fabpot fabpot merged commit 8a1fba8 into symfony:6.3 Oct 16, 2023
7 of 9 checks passed
@HypeMC HypeMC deleted the fix-graceful-exit branch October 16, 2023 23:14
fabpot added a commit that referenced this pull request Oct 17, 2023
This PR was merged into the 6.3 branch.

Discussion
----------

[Messenger] Simplify code

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT

Follow up to #52080

Commits
-------

49a452d [Messenger] Simplify code
fabpot added a commit that referenced this pull request Oct 20, 2023
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
@fabpot fabpot mentioned this pull request Oct 21, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants