0

I'm working on a geocoding piece/sidekiq job in a Rails/Ruby app. So basically when we hit the Google API we sleep for 1 second to avoid the Google API query limit. But I want to push the envelope and speed up processing a bit taking into account AR and SQL time. So I'm trying to figure out how to sleep for 3/4 of a second.

Can I just do sleep .75 or do I need to do some sort of math on sleep like sleep(1.0 / ??).

Not sure if sleep can take a float like .75 or not. Any thoughts on this?

nulltek
  • 3,247
  • 9
  • 44
  • 94
  • Sorry, I was away from my computer and posting from my phone. I should have RTFM first. Ignore my question. – nulltek Jul 27 '15 at 17:49

1 Answers1

16

sleep 0.75 works pretty good and correct. It accepts float.

sleep(*args) public Suspends the current thread for duration seconds (which may be any number, including a Float with fractional seconds)

http://apidock.com/ruby/Kernel/sleep

adamliesko
  • 1,887
  • 1
  • 14
  • 21
  • 1
    Thanks for the quick answer and pointing me in the right direction, I should have looked at the API docs before asking. I was mobile and was just thinking out loud. Appreciate your answer, sorry for the dupe question. – nulltek Jul 27 '15 at 17:54