[Tutor] Trapping HTTP Authentication Failure
Michael Powe
michael at trollope.org
Fri Sep 10 21:10:13 CEST 2010
Hello,
My script to call a web service authenticates. I would like to be
able to trap an exception if the authentication fails. The script
loops over a list of dates and I don't want it to retry for every
element in the list. This could take a long time and be very annoying
when, after the long wait, a stacktrace spews out of the last attempt.
The assumption is that if it fails, it is not a transient network or
some other issue but that the credentials themselves are faulty.
Now, the authentication header is sent with the initial request, so it
does not look to me like the standard process of request, get a 401
and then re-request with credentials is relevant. However, clearly
the opener issues a number of retries after the initial failure.
But, I don't see a mechanism in urllib2 for taking notice of a failure
and acting on it.
Can somebody point me toward a solution?
Thanks.
mp
--
Michael Powe michael at trollope.org Naugatuck CT USA
"And I'd be a Libertarian, if they weren't all a bunch of tax-dodging
professional whiners." -- Berke Breathed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20100910/ca068022/attachment-0001.pgp>
More information about the Tutor
mailing list