-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[Process] Add explanation on how to make the Process survive a response #7159
Conversation
Fixes symfony#7151 It confuses user that could be tempted to use the Asynchronous Process feature to achieve long running task after the Response is sent. The result is the following : from no code execution (if you send a Response really fast) to partial code execution
|
||
If you want your process to survive the request/response cycle, you could take | ||
advantage of the ``kernel.terminate`` event, and run your command **synchronuously** | ||
inside this event. Be aware that ``kernel.terminate`` is called only if you run ``PHP-FPM``. |
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.
Beware also that if you do that, the said php process won't available to serve any new request until the subprocess is finished, which means you can block your FPM pool quickly if you're not careful enough. That's why it generally way better to not do any fancy thing even after the request is sent but prefer using a job queue.
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.
Do you want me to add a note to include this remark ?
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.
Yes, I think that's an important note that should be added inside a caution
block.
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.
@xabbuh done !
any updates I can do for you to merge this ? |
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.
Left some minor comments thanks! 👍
|
||
.. caution:: | ||
|
||
Beware also that if you do that, the said php process won't available to serve |
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.
won't be
Beware also that if you do that, the said php process won't available to serve | ||
any new request until the subprocess is finished, which means you can block your | ||
FPM pool quickly if you're not careful enough. | ||
That's why it generally way better to not do any fancy thing even after the request is sent |
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.
it's generally
Thank you @tristanbes. |
…ive a response (tristanbes, javiereguiluz) This PR was merged into the 2.7 branch. Discussion ---------- [Process] Add explanation on how to make the Process survive a response Fixes #7151 It clarifies the situation for users that could be tempted to use the asynchronous `Process` feature to achieve long running task after the Response is sent which won't work. It goes from no code execution (if you send a Response really fast) to partial code execution. Commits ------- cdf248c add a caution block about php-fpm pool 020f1b7 Fixed some syntax issues 64de236 Add explanation how to make the Process survive a response
My pleasure |
Fixes #7151
It clarifies the situation for users that could be tempted to use the asynchronous
Process
feature to achieve long running task after the Response is sent which won't work.It goes from no code execution (if you send a Response really fast) to partial code execution.