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