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

[Process] Add explanation on how to make the Process survive a response #7159

Merged
merged 3 commits into from
Mar 13, 2017

Conversation

tristanbes
Copy link
Contributor

@tristanbes tristanbes commented Nov 22, 2016

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.

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
@tristanbes tristanbes changed the title [Process] Add explanation how to make the Process survive a response [Process] Add explanation on how to make the Process survive a response Nov 22, 2016

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``.
Copy link
Member

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.

Copy link
Contributor Author

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 ?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh done !

@tristanbes
Copy link
Contributor Author

any updates I can do for you to merge this ?

Copy link
Contributor

@HeahDude HeahDude left a 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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's generally

@xabbuh
Copy link
Member

xabbuh commented Mar 13, 2017

Thank you @tristanbes.

@xabbuh xabbuh merged commit cdf248c into symfony:2.7 Mar 13, 2017
xabbuh added a commit that referenced this pull request Mar 13, 2017
…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
xabbuh added a commit that referenced this pull request Mar 13, 2017
xabbuh added a commit that referenced this pull request Mar 13, 2017
@tristanbes
Copy link
Contributor Author

My pleasure

@tristanbes tristanbes deleted the process branch March 13, 2017 10:36
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.

6 participants