Permalink
Browse files

Stop EM reactor when is necessary

  • Loading branch information...
rnaveiras committed Aug 14, 2012
1 parent 4d366c1 commit 070889c83cfd7586cdb2067c15039d9643b9bfc2
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/eventwire/adapters/safe_amqp.rb
@@ -8,12 +8,14 @@ def initialize(options = {})
end
def publish(event_name, event_data = nil)
+ keep_reactor_loop = EM.reactor_running?
+
connect_asynch do |conn|
AMQP::Channel.new(conn) do |channel|
channel.confirm_select
channel.on_ack do |basic_ack|
channel.close
- stop
+ stop unless keep_reactor_loop
end
fanout = channel.fanout(event_name.to_s, :durable => true)
fanout.publish(event_data, :persistent => true)

1 comment on commit 070889c

@cavalle

This comment has been minimized.

Show comment Hide comment
@cavalle

cavalle Aug 14, 2012

Owner

Good catch! I remember doing something similar in the original Movida code

Owner

cavalle commented on 070889c Aug 14, 2012

Good catch! I remember doing something similar in the original Movida code

Please sign in to comment.