Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use normal condition instead of lambda usage

  • Loading branch information...
commit 3215c89822f7147b1a0bdc6d7fa6248a892b609b 1 parent 74779ec
@grobie grobie authored
Showing with 16 additions and 16 deletions.
  1. +16 −16 lib/minion.rb
View
32 lib/minion.rb
@@ -50,24 +50,24 @@ def job(queue, options = {}, &blk)
end
handler.sub = lambda do
log "subscribing to #{queue}"
- subscribe_handler = lambda do |h,m|
- return if AMQP.closing?
- begin
- log "recv: #{queue}:#{m}"
-
- args = decode_json(m)
-
- result = yield(args,h)
-
- next_job(args, result)
- rescue Object => e
- raise unless error_handler
- error_handler.call(e,queue,m,h)
+ MQ.queue(queue, :durable => true, :auto_delete => false).subscribe(:ack => true) do |h,m|
+ unless AMQP.closing?
+ begin
+ log "recv: #{queue}:#{m}"
+
+ args = decode_json(m)
+
+ result = yield(args,h)
+
+ next_job(args, result)
+ rescue Object => e
+ raise unless error_handler
+ error_handler.call(e,queue,m,h)
+ end
+ h.ack
+ check_all
end
- h.ack
- check_all
end
- MQ.queue(queue, :durable => true, :auto_delete => false).subscribe(:ack => true, &subscribe_handler)
end
@@handlers ||= []
at_exit { Minion.run } if @@handlers.size == 0
Please sign in to comment.
Something went wrong with that request. Please try again.