Created
December 1, 2018 10:22
-
-
Save 2rba/74d57775ac83ffcb0ff1da5eb5371212 to your computer and use it in GitHub Desktop.
Capybara 3.12.0 + Puma 3.10.0 + TimeCop Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CoreExtensions | |
module Puma | |
module Reactor | |
def calculate_sleep | |
if @timeouts.empty? | |
@sleep_for = ::Puma::Reactor::DefaultSleepFor | |
else | |
diff = @timeouts.first.timeout_at.to_f - Time.now.to_f | |
if diff < 0.0 | |
@sleep_for = 0 | |
elsif diff > 60 | |
@sleep_for = ::Puma::Reactor::DefaultSleepFor | |
else | |
@sleep_for = diff | |
end | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fix Puma + TimeCop issue https://github.com/puma/puma/issues/1582 | |
require 'puma/reactor' | |
Puma::Reactor.prepend CoreExtensions::Puma::Reactor |
You should pull in global ::Time.now.to_f
otherwise this clashes with CoreExtensions::Time
which has no now
method:
Error reached top of thread-pool: undefined method `now' for CoreExtensions::Time:Module (NoMethodError)
Error in reactor loop escaped: undefined method `now' for CoreExtensions::Time:Module (NoMethodError)
/work/YetAnotherCryptoApp/spec/support/reactor.rb:12:in `calculate_sleep'
Original issue described here: puma/puma#1582
This is no longer an issue in Puma 4.x
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will this be included in a new release soon?