Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:38:06+00:00 2026-06-09T16:38:06+00:00

I am continuously calling an API and keep getting Stack level too deep error

  • 0

I am continuously calling an API and keep getting Stack level too deep error within minutes of call. I guess I am missing something basic here:

Class SomeModel

  def self.call_api(index)
    ref = SomeModel.get_reference
    query ||=  Api.call(:parameter => ref.parameter, :offset => index)
    # .. doing stuff
    if index >= 949
      sleep(20)
      new_num = Integer(number) + 1000
      ref.update_attribute(:parameter, new_num)      
      SomeModel.call_api(1)
     else
       sleep(10)
       begin
             # This is a rescue for the case when API call returns nothing.
         SomeModel.call_api(index+50)
       rescue
         new_num = Integer(number) + 1000
         ref.update_attribute(:parameter, new_num)
         SomeModel.call_api(1)
       end
    end
  end

end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:38:07+00:00Added an answer on June 9, 2026 at 4:38 pm

    Ruby does not handle recursion well and will always eventually give you a stack level too deep. You’re better off putting this inside some sort of loop that does not call the method recursively. If you want it to be a little smarter than just calling the method in an infinite loop, you can use something like EventMachine to respond to different events.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am continuously getting Error Code The ORA-01033: ORACLE initialization or shutdown in progress
I am continuously getting an Access Violation Error with a all my kernels which
I'm using C# to continuously search for multiple string keywords within large strings, which
I continuously get an error when I open all text and log files in
Usually not calling Dispose indicates a possible error or sloppy code and may lead
I'm getting UDP packets from the port continuously. Following is the log from wireshark.
How can I continuously get the position of the mouse whilst its button is
i am doing a continuously select every 10seconds, so i thought i would do
I have a C# application..I continuously get a null reference exception..I manage to catch
I have created a desktop application which continuously changes the image on a fixed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.