Skip to content

Instantly share code, notes, and snippets.

@dhananjaysathe
Last active August 25, 2015 20:02
Show Gist options
  • Save dhananjaysathe/b7d5e970637581304b43 to your computer and use it in GitHub Desktop.
Save dhananjaysathe/b7d5e970637581304b43 to your computer and use it in GitHub Desktop.
Possible to fix race conditions
diff --git a/lib/bunny/channel.rb b/lib/bunny/channel.rb
index 236f41c..4a500da 100644
--- a/lib/bunny/channel.rb
+++ b/lib/bunny/channel.rb
@@ -230,9 +230,9 @@ module Bunny
# {Bunny::Queue}, {Bunny::Exchange} and {Bunny::Consumer} instances.
# @api public
def close
+ @work_pool.shutdown
@connection.close_channel(self)
@status = :closed
- @work_pool.shutdown
maybe_kill_consumer_work_pool!
end
diff --git a/lib/bunny/consumer_work_pool.rb b/lib/bunny/consumer_work_pool.rb
index fe84404..49ba0ab 100644
--- a/lib/bunny/consumer_work_pool.rb
+++ b/lib/bunny/consumer_work_pool.rb
@@ -58,6 +58,9 @@ module Bunny
throw :terminate
end
end
+ while busy?
+ sleep 0.1
+ end
end
def join(timeout = nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment