-
I was trying to use Excon gem with async, but unfortunatelly it does not work:
I'm wondering what decides that something works in async way. @ioquatix Is it possible to put some light on this topic? I found it surprising after reading https://brunosutic.com/blog/async-ruby |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
I did a quick dive into the gem source code. The gem is using non-blocking method calls in a loop: https://github.com/excon/excon/blob/master/lib/excon/socket.rb#L179-L181 From what I can tell, this is effectively busy-waiting for the responses. There's probably a reason behind that, but the downside is that non-blocking methods don't work with async (or more precisely: with fiber scheduler). To quote the linked article:
Even |
Beta Was this translation helpful? Give feedback.
-
Hi
This is what I observed with my quick debugging yesterday.
Yea, maybe try making Also, can you avoid using the built-in selector, because I think waiting on |
Beta Was this translation helpful? Give feedback.
-
Another idea regarding the default |
Beta Was this translation helpful? Give feedback.
-
Ok, I've tried to make the obvious/easy changes at least to get the readline implementation back to respecting the nonblock setting: excon/excon#782. Hopefully this solves the immediate issue. I'd welcome help in verifying that this works as expected now, as I'm not familiar with async and don't have reproduction/test code handy at present. From some of the other comments it sounds like there might be some better ways to implement some of the other parts as well, but I was less confident about the specifics (my previous experience with IO stuff involved a lot of trial and error if I recall). @ioquatix I'm interested in continuing to improve the code and do the waiting in a better way. Are there good examples of using |
Beta Was this translation helpful? Give feedback.
Ok, I've tried to make the obvious/easy changes at least to get the readline implementation back to respecting the nonblock setting: excon/excon#782. Hopefully this solves the immediate issue. I'd welcome help in verifying that this works as expected now, as I'm not familiar with async and don't have reproduction/test code handy at present.
From some of the other comments it sounds like there might be some better ways to implement some of the other parts as well, but I was less confident about the specifics (my previous experience with IO stuff involved a lot of trial and error if I recall).
@ioquatix I'm interested in continuing to improve the code and do the waiting in a better way. Are…