-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hangs after warning: "Waiting for pool to drain" from Async::HTTP::Client #6
Comments
|
It's clear from the stacktrace that is failing to set up the reactor:
|
Appending a This is not very intuitive at all, but I'm not sure how I could expect a library centered around asynchronous I/O to perform the read "for me". I am torn here.
|
You can call finish or close on the response object. Close will immediately terminate the connection and discard any response body. If there is no response body the connection will return to the connection pool. Finish will gracefully finish reading the response and return the connection to the pool. |
The last reply was from my phone. Here are a few more thoughts... So, basically, when you make request, the response is provided as soon as the server responds with a complete set of headers. This is a bit different from other libraries that will fully read/buffer the response data too. In the past, these operations were a little bit different: https://github.com/socketry/protocol-http/blob/master/lib/protocol/http/body/reader.rb#L48-L57 The logic to these methods right now, is that once you read the body, it's finished. Previously,
This allowed you to cache the body in the response... but once you call So, the logic of the response is you must do one of those things: https://github.com/socketry/protocol-http/blob/master/lib/protocol/http/body/reader.rb#L27-L76 I'm open to ideas about how to do this better. However, maybe there is something wrong with async-rest too - i.e. maybe there should be slightly higher methods. That being said, it should be in your hands how to deal with methods like So, async-rest/lib/async/rest/representation.rb Lines 114 to 123 in a3ba050
Looking at your logic:
The biggest issue with this is you are ignoring the response status. It might fail, which should raise an error. What is the response of patch, does it update the state of the object? If there is some kind of standard model, I'd be willing to consider figuring out the semantic model that works better. For example, my preference is something like this:
Anyway, the logic of reading responses should probably follow the same path through the wrapper... unless there is some specific reason not to. |
Even for a POC, yes: ignoring the response status is bad. 👍 I am completely new to the methodologies needed for async REST API calls - so this is good stuff. I have worked through the issues on my side by making sure to always I like the idea you have of making sure these calls go through the wrapper. |
Side question, @ioquatix, can you point me to any basic resources for the following:
|
Make sure you use It enables debug assertions and other checks.
There is support for this in webmock and we are also building a native wrapper to enable mocked requests/responses, which should be a little bit better: socketry/async-http#41
This could probably be improved. Logging payloads is a bit more tricky.
will enable logging from instances of |
Awesome, that gives me enough to get going for now! Thank you. |
I am going to close this issue as it appears your problems are resolved. |
Clearly, I am doing something wrong.
I have two successful GET requests, via an
Async::REST::Representation
, then my following PATCH request gives the following warning - and then the script hangs forever:If it will be useful, I can post my code. It does not have any explicit reactor usage, it's just letting the framework take care of instantiating the reactor every time (which I know is not very performant, but it's just a test script for now).
The text was updated successfully, but these errors were encountered: