[Tutor] Trapping HTTP Authentication Failure
Evert Rol
evert.rol at gmail.com
Sat Sep 11 01:28:26 CEST 2010
> My script to call a web service authenticates.
Sorry, but where is the (full) script? I missed an attachment or (preferably) a link.
> 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
More information about the Tutor
mailing list