Skip to content

Commit 64de236

Browse files
committed
Add explanation how to make the Process survive a response
Fixes #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
1 parent ed3ae3c commit 64de236

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/process.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ are done doing other stuff::
124124
which means that your code will halt at this line until the external
125125
process is completed.
126126

127+
.. note::
128+
If a `Response` is sent **before** what `Process` is running had a chance to complete,
129+
the server process will be killed (depending on your OS). It means that your task
130+
will be stopped right away.
131+
Running an asynchronous process is not the same than running a processing surviving yourselves.
132+
133+
If you want your process to survive the request/response cycle, you could take
134+
advantage of the `kernel.terminate` event, and run your command **synchronuously**
135+
inside this event. Be aware that `kernel.terminate` is called only if you run `PHP-FPM`.
136+
127137
:method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument:
128138
a callback that is called repeatedly whilst the process is still running, passing
129139
in the output and its type::

0 commit comments

Comments
 (0)