3 ms·
I might be old-fashioned, but I would not start any background processing in the context of the process that handles the request. Depending on the web server ha
by pilif 16y ago
I might be old-fashioned, but I would not start any background processing in the context of the process that handles the request. Depending on the web server handling the request, your process (threads are subprocesses) can be killed at any time when it's not serving a request.
That could either kill your threads or prevent the webserver from correctly shutting down the process or handling another request on the same process.
I would hand the background jobs off to some daemon process or write instructions describing the job into some queue and then have a cron job process them.
I would never expect to be able to keep anything running after request processing has finished.