Score:2

How to handle batch operations when the user machine gets into suspended mode?

sy flag

I'm importing a large dataset into the database using the BatchBuilder in Drupal. It takes more than one and a half hours to complete all the operations in the batch. The process starts with user action on a page, and the progress of the batch operation is shown to the user. We are facing an error on the batch process if there's a connectivity issue on the user side. For example, if the user started the batch process in a tab and left the machine idle. After some time, the machine enters into suspended mode, and the internet connection won't be available. This will halt the batch process, and the entire progress made will be gone.

Screenshot of the batch process running. Running the batch process

Runs into an error if there's a connection issue on the user end. Runs into error on connectivity issues

Is there any way or workarounds to fix this? May be like changing the batch operation to the server side from the client side.

Kevin avatar
in flag
The connection to the client cannot be killed. They can prevent the machine from going into suspend mode. Otherwise create/run Drush commands to do this same work in the background from a scheduled job.
id flag
There are apps that prevent hibernation at the touch of a button, for example: https://apps.apple.com/us/app/amphetamine/id937984704?mt=12 Use one.
leymannx avatar
ne flag
That's a job for the Queue API that will finish things on cron. User action will add items to queue. Cron will process. No session necessary.
apaderno avatar
us flag
Batch operations require the browser to stay connected to the server for the full duration of the operations. Once the browser disconnects from the server, batch operations are interrupted. The only way to avoid that is using Drush or using the queue API and cron tasks, but in the latter case, it will be necessary to run cron more times.
apaderno avatar
us flag
(Essentially, with batch operations, it is the browser that causes the operations to progress, by requesting a page at pre-set intervals and with a different parameter value.)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.