GithubHelp home page GithubHelp logo

Comments (1)

RobsonKing avatar RobsonKing commented on June 17, 2024

This request help me work around a related problem... We found that some of our tests can fail if they happen to run during the time rack attack has chosen as the expiry.... Since it seems like the expiry is chosen based on a modulus of time...

def sleep_if_required(interval)
  # rack attack uses a modulus of time to choose when to rest things...
  # https://github.com/rack/rack-attack/blob/d7a7a8bda5cba232d8d5d300b95cef79d40cc528/lib/rack/attack/cache.rb#L69

  # so if we are running when the reset is going to happen... our test can fail :(
  # so if it looks like we are going to be close... sleep until the start of the new period

  mod = Time.now.to_i % interval
  dif = interval - mod
  if dif < 2
    puts "sleeping till new rack attack period #{(dif + 1)}"
    sleep((dif + 1).seconds)
  end
end

Its not a great solution, and i would love some other test helper that could help work around this...

from rack-attack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.