Skip to content

Conversation

@ColorFuzzy
Copy link
Contributor

There may be three different Timeout in SimpleAsyncHTTPClient

They all raise "HTTP 599: Timeout", it would be more convenient to debug timeout problem with more detailed information. In this pull request, different timeout type will have different error message. Those messages are:

  1. "HTTP 599: Timeout in request queue"
  2. "HTTP 599: Timeout while connecting"
  3. "HTTP 599: Timeout during request"

@bdarnell
Copy link
Member

You don't need to close a PR and open a new one to make changes; you can push new commits to your branch and the PR will be updated.

The test is complicated and looks fragile (for example, it'll break with HTTP/2). I'm pretty sure we don't want to monkey-patch _handle_exception here - if that function is doing something inappropriate, it should be fixed and not patched for this test. It's not clear to me why you're doing what you're doing there.

I think it should be possible to test this with just a custom resolver (a non-blocking resolver that never completes). Does something like this work?

    class TimeoutResolver(Resolver):
        def resolve(self, *args, **kwargs):
            return Future()  # never completes

    client = self.create_client(resolver=TimeoutResolver()))
    self.addCleanup(client.close)
    client.fetch(self.get_url('/hello'), self.stop,
                     connect_timeout=connect_timeout)
    response = self.wait()
    self.assertEqual(response.code, 599)
    self.assertTrue(timeout_min < response.request_time < timeout_max,
                    response.request_time)
    self.assertEqual(str(response.error), "HTTP 599: Timeout while connecting")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"while interacting" sounds weird; maybe "during request"?

@ColorFuzzy
Copy link
Contributor Author

All right, I'll make some change.

@ColorFuzzy
Copy link
Contributor Author

A non-blocking resolver that never completes works pretty well!😊

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should subclass Resolver, not BlockingResolver.

@ColorFuzzy
Copy link
Contributor Author

Updated, pretty thanks!

bdarnell added a commit that referenced this pull request Dec 31, 2015
Differentiate HTTPError(599, "Timeout") raised by SimpleAsyncHTTPClient
@bdarnell bdarnell merged commit 6b312f7 into tornadoweb:master Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants