-
Notifications
You must be signed in to change notification settings - Fork 132
Worker Pause Logic Explanation
gresrun edited this page Nov 30, 2012
·
1 revision
So let's walk through a scenario; we have a single worker and a single client and a job type that takes a long time.
- Client enqueues the job
- Worker takes the job and begins processing - Worker.isPaused() == false - Worker.isProcessingJob() == true - Worker's status as reported in Redis is showing the current job. (This is what is shown in (R/J)esque-Web Console)
- Client (via an AdminClient) issues a togglePausedWorkers(true) command
- Worker's Admin receives and processes the pause command, which calls Worker.togglePause(true) - Worker.isPaused() == true - Worker.isProcessingJob() == true - Worker's status as reported in Redis is still showing the current job.
- Worker completes the current job. - Worker.isPaused() == true - Worker.isProcessingJob() == false - Worker's status as reported in Redis is now "paused"
So, in effect, Worker.isPaused() is indicative of whether the Worker has been asked to be paused and can be used in conjunction with Worker.isProcessingJob() to see if it has paused yet. The status in Redis does not indicate whether the Worker has been asked to be paused but is only the actual state (paused or processing a job).