shazow/urllib3 — pull request #326 by kevinburke (2014-01-28 01:52:07+00:00)
Title: Retries

Okay:

- Adds support for retries, per the spec we laid out (mostly).
- Adds docs etc.
- Splits out util.py into submodules - I need to know what you want to do here because as written it would change from `urllib3.util.Timeout` into `urllib3.util.timeout.Timeout` which is not good.
- adds a new /successful_retry handler to the DummyTestCase which keys based on a `test-name` header and returns 200 only after the request has been retried once.
- I believe there are some API changes here.
- some subclasses of httplib.HTTPException can actually be raised as connection errors because they imply the request never actually got sent to the server.
- urlopen previously would retry on read timeouts, which violated the urlopen contract (as I understood it) of only retrying things that couldn't possibly be side effecting. this code does not retry read timeouts by default.

I am also testing this in two new environments - in the office which places my IP on 10.* subnet and I think has weird/different behavior when connecting to TARPIT_HOST than do standard wifi networks, and without an Internet connection, in which case a bunch of tests fail. Also, it's difficult to test some of these exceptional cases because the errors raised rely on the network stack, which (I think) is why the tests are failing on the branch. I'm still looking into it.

Either way I am losing some confidence in the connection timeout tests; getting a network to reliably generate ECONNREFUSED, or not generate it and tie up a connection, is tricky, unless we want to go down a path like this: http://bugs.python.org/file26890/test_timeout.patch