8000 [Process] Add explanation how to make the Process survive a request/r… · tristanbes/symfony-docs@673c0e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 673c0e5

Browse files
authored
[Process] Add explanation how to make the Process survive a request/response
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
1 parent f0db5af commit 673c0e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/process.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ are done doing other stuff::
142142
The :method:`Symfony\\Component\\Process\\Process::wait` method is blocking,
143143
which means that your code will halt at this line until the external
144144
process is completed.
145+
146+
.. note::
147+
If a `Response` is sent **before** what `Process` is running had a chance to complete,
148+
the server process will be killed (depending on your OS). It means that your task
149+
will be stopped right away.
150+
Running an asynchronous process is not the same than running a processing surviving yourselves.
151+
152+
If you want your process to survive the request/response cycle, you could take
153+
advantage of the `kernel.terminate` event, and run your command **synchronuously**
154+
inside this event. Be aware that `kernel.terminate` is called only if you run `PHP-FPM`.
155+
145156

146157
:method:`Symfony\\Component\\Process\\Process::wait` takes one optional argument:
147158
a callback that is called repeatedly whilst the process is still running, passing

0 commit comments

Comments
 (0)
0