File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -148,11 +148,11 @@ def work(interval = 5.0, &block)
148
148
nil
149
149
end
150
150
else
151
- unregister_signal_handlers if ! @cant_fork && term_child
151
+ unregister_signal_handlers if will_fork? && term_child
152
152
procline "Processing #{ job . queue } since #{ Time . now . to_i } "
153
153
redis . client . reconnect # Don't share connection with parent
154
154
perform ( job , &block )
155
- exit! unless @cant_fork
155
+ exit! if will_fork?
156
156
end
157
157
158
158
done_working
@@ -229,14 +229,12 @@ def queues
229
229
# Not every platform supports fork. Here we do our magic to
230
230
# determine if yours does.
231
231
def fork
232
- @cant_fork = true if $TESTING
233
-
234
232
return if @cant_fork
235
233
236
234
begin
237
235
# IronRuby doesn't support `Kernel.fork` yet
238
236
if Kernel . respond_to? ( :fork )
239
- Kernel . fork
237
+ Kernel . fork if will_fork?
240
238
else
241
239
raise NotImplementedError
242
240
end
@@ -507,6 +505,10 @@ def working?
507
505
def idle?
508
506
state == :idle
509
507
end
508
+
509
+ def will_fork?
510
+ !( @cant_fork || $TESTING)
511
+ end
510
512
511
513
# Returns a symbol representing the current worker state,
512
514
# which can be either :working or :idle
You can’t perform that action at this time.
0 commit comments