@@ -101,47 +101,50 @@ How do the workers process the queues?
101
101
8 . ` Resque_Job->fail() ` returns control to the worker (still in
102
102
` Resque_Worker::work() ` ) without a value
103
103
* Job
104
- 1 . The job calls ` Resque_Worker->perform() ` with the ` Resque_Job ` as its
104
+ 1 . ` Resque_Job_PID ` is created, registering the PID of the actual process
105
+ doing the job.
106
+ 2 . The job calls ` Resque_Worker->perform() ` with the ` Resque_Job ` as its
105
107
only argument.
106
- 2 . ` Resque_Worker->perform() ` sets up a ` try...catch ` block so it can
108
+ 3 . ` Resque_Worker->perform() ` sets up a ` try...catch ` block so it can
107
109
properly handle exceptions by marking jobs as failed (by calling
108
110
` Resque_Job->fail() ` , as above)
109
- 3 . Inside the ` try...catch ` , ` Resque_Worker->perform() ` triggers an
111
+ 4 . Inside the ` try...catch ` , ` Resque_Worker->perform() ` triggers an
110
112
` afterFork ` event
111
- 4 . Still inside the ` try...catch ` , ` Resque_Worker->perform() ` calls
113
+ 5 . Still inside the ` try...catch ` , ` Resque_Worker->perform() ` calls
112
114
` Resque_Job->perform() ` with no arguments
113
- 5 . ` Resque_Job->perform() ` calls ` Resque_Job->getInstance() ` with no
115
+ 6 . ` Resque_Job->perform() ` calls ` Resque_Job->getInstance() ` with no
114
116
arguments
115
- 6 . If ` Resque_Job->getInstance() ` has already been called, it returns the
117
+ 7 . If ` Resque_Job->getInstance() ` has already been called, it returns the
116
118
existing instance; otherwise:
117
- 7 . ` Resque_Job->getInstance() ` checks that the job's class (type) exists
119
+ 8 . ` Resque_Job->getInstance() ` checks that the job's class (type) exists
118
120
and has a ` perform() ` method; if not, in either case, it throws an
119
121
exception which will be caught by ` Resque_Worker->perform() `
120
- 8 . ` Resque_Job->getInstance() ` creates an instance of the job's class, and
122
+ 9 . ` Resque_Job->getInstance() ` creates an instance of the job's class, and
121
123
initializes it with a reference to the ` Resque_Job ` itself, the job's
122
124
arguments (which it gets by calling ` Resque_Job->getArguments() ` , which
123
125
in turn simply returns the value of ` args[0] ` , or an empty array if no
124
126
arguments were passed), and the queue name
125
- 9 . ` Resque_Job->getInstance() ` returns control, along with the job class
127
+ 10 . ` Resque_Job->getInstance() ` returns control, along with the job class
126
128
instance, to ` Resque_Job->perform() `
127
- 10 . ` Resque_Job->perform() ` sets up its own ` try...catch ` block to handle
129
+ 11 . ` Resque_Job->perform() ` sets up its own ` try...catch ` block to handle
128
130
` Resque_Job_DontPerform ` exceptions; any other exceptions are passed
129
131
up to ` Resque_Worker->perform() `
130
- 11 . ` Resque_Job->perform() ` triggers a ` beforePerform ` event
131
- 12 . ` Resque_Job->perform() ` calls ` setUp() ` on the instance, if it exists
132
- 13 . ` Resque_Job->perform() ` calls ` perform() ` on the instance
133
- 14 . ` Resque_Job->perform() ` calls ` tearDown() ` on the instance, if it
132
+ 12 . ` Resque_Job->perform() ` triggers a ` beforePerform ` event
133
+ 13 . ` Resque_Job->perform() ` calls ` setUp() ` on the instance, if it exists
134
+ 14 . ` Resque_Job->perform() ` calls ` perform() ` on the instance
135
+ 15 . ` Resque_Job->perform() ` calls ` tearDown() ` on the instance, if it
134
136
exists
135
- 15 . ` Resque_Job->perform() ` triggers an ` afterPerform ` event
136
- 16 . The ` try...catch ` block ends, suppressing ` Resque_Job_DontPerform `
137
+ 16 . ` Resque_Job->perform() ` triggers an ` afterPerform ` event
138
+ 17 . The ` try...catch ` block ends, suppressing ` Resque_Job_DontPerform `
137
139
exceptions by returning control, and the value ` FALSE ` , to
138
140
` Resque_Worker->perform() ` ; any other situation returns the value
139
141
` TRUE ` along with control, instead
140
- 17 . The ` try...catch ` block in ` Resque_Worker->perform() ` ends
141
- 18 . ` Resque_Worker->perform() ` updates the job status from ` RUNNING ` to
142
+ 18 . The ` try...catch ` block in ` Resque_Worker->perform() ` ends
143
+ 19 . ` Resque_Worker->perform() ` updates the job status from ` RUNNING ` to
142
144
` COMPLETE ` , then returns control, with no value, to the worker (again
143
145
still in ` Resque_Worker::work() ` )
144
- 19 . ` Resque_Worker::work() ` calls ` exit(0) ` to terminate the job process
146
+ 20 . ` Resque_Job_PID() ` is removed, the forked process will terminate soon
147
+ 21 . ` Resque_Worker::work() ` calls ` exit(0) ` to terminate the job process
145
148
cleanly
146
149
* SPECIAL CASE: Non-forking OS (Windows)
147
150
1 . Same as the job above, except it doesn't call ` exit(0) ` when done
0 commit comments