Code Monkey home page Code Monkey logo

Comments (5)

godfat avatar godfat commented on August 12, 2024

According to the stack trace, could it be waiting for the response from the
remote server? Did you setup any timeout? If yes, it could probably be a
bug in rest-core somewhere... otherwise, try to setup some timeout?

from rest-core.

davidhq avatar davidhq commented on August 12, 2024

I didn't have a timeout... so like this: use RC::Timeout, 30 ?

from rest-core.

godfat avatar godfat commented on August 12, 2024

Sorry for the late response. Yes, that would effectively make all the requests
default to 30 seconds timeout. However, I just checked the HTTP client used
underneath rest-core, there should have some default timeout:
https://github.com/nahi/httpclient/blob/v2.5.3.3/lib/httpclient/session.rb#L133-L139
According to your stack trace, it should be receiving some data, therefore it should
have maximum 60 seconds for connecting and 60 seconds for receiving, if you're
posting some data, maybe add another 120 seconds, that means it should
never block more than 240 seconds.

The other possibility to block indefinitely might be, if you're using thread pool by
setting something like this: YourClient.pool_size = 10, then you can't nest
callbacks more than 10 levels.

For example, suppose the pool size was 1, then this would deadlock:

require 'rest-core'
RC::Universal.pool_size = 1
client = RC::Universal.new
client.get('http://example.com/1') do |_|
  puts client.get('http://example.com/2')
end
client.wait # DEADLOCK

This is because a request is only considered done when the callback is
also called, but above we tried to make a second request in the first callback,
waiting for the first callback to be done, but it's never going to be. Therefore
the second request can never begin, and the first callback could never be done.
We could try to detect this deadlock and raise some errors, but I haven't tried to
do so at the moment.

If you're not using callbacks nor thread pool, then nothing should really deadlock.
If you have any ideas what might go wrong, it would be much appreciated.

from rest-core.

davidhq avatar davidhq commented on August 12, 2024

Thank you very much! I will observe further and also leave my timeout in...

will come back if I have more info that could be helpful...

from rest-core.

godfat avatar godfat commented on August 12, 2024

Thank you for trying and reporting :)
Personally I never see this kind of issues, but honestly
I am not too confident if everything is alright.
So please do let me know if there's anything I could help.
Thanks!

from rest-core.

Related Issues (18)

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.