You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to figure out how to perform a graceful shutdown. The documentation states that when executing queue.pause(true), a promise is returned that resolves when the queue is paused. It will not process any new jobs and active jobs will continue until they complete. It relies on Queue#whenCurrentJobsFinished, which returns a promise that resolves when all jobs currently being processed by a given worker have finished.
Looking into Queue#whenCurrentJobsFinished, it appears that it does not wait for all active jobs to finish, but rather wait for a single job to complete.
/**
* Returns a promise that resolves when active jobs are finished
*
* @returns {Promise}
*/
Queue.prototype.whenCurrentJobsFinished = function() {
if (!this.bclientInitialized) {
// bclient not yet initialized, so no jobs to wait for
return Promise.resolve();
}
//
// Force reconnection of blocking connection to abort blocking redis call immediately.
//
const forcedReconnection = redisClientDisconnect(this.bclient).then(() => {
return this.bclient.connect();
});
return Promise.all([this.processing[0]]).then(() => {
return forcedReconnection;
});
};
Why not wait for all jobs in this.processing to finish before resolving?
I am currently using a concurrency value of 12, meaning that you would need to wait for at most 12 promises to resolve.
Description
Hi!
I was trying to figure out how to perform a graceful shutdown. The documentation states that when executing queue.pause(true), a promise is returned that resolves when the queue is paused. It will not process any new jobs and active jobs will continue until they complete. It relies on Queue#whenCurrentJobsFinished, which returns a promise that resolves when all jobs currently being processed by a given worker have finished.
Looking into Queue#whenCurrentJobsFinished, it appears that it does not wait for all active jobs to finish, but rather wait for a single job to complete.
Why not wait for all jobs in this.processing to finish before resolving?
I am currently using a concurrency value of 12, meaning that you would need to wait for at most 12 promises to resolve.
This change would enable me to perform a perfect shutdown. Looking forward to hearing your thoughts!
The text was updated successfully, but these errors were encountered: