requests.{get,post} timeout

Chris Angelico rosuav at gmail.com
Wed Aug 23 19:18:49 EDT 2017


On Thu, Aug 24, 2017 at 8:54 AM, Jon Ribbens <jon+usenet at unequivocal.eu> wrote:
> On 2017-08-23, Chris Angelico <rosuav at gmail.com> wrote:
>> Yes and no. If requests provided a 'cancel query' feature, it would
>> play nicely with everything else, but (a) the entire concept here is
>> that the request has stalled, so you COULD just ignore the pending
>> query and pretend it's failed without actually cancelling it; and (b)
>> you could just close the underlying socket without help, but it might
>> mess up future queries that end up getting put onto the same socket.
>> It's not that you CAN'T do this without help (which is the case for a
>> "time between bytes" timeout), but that having help would allow
>> requests *itself* to benefit.
>
> I don't understand - in the above paragraph you first explain how
> it cannot be done without help from requests, then you state that it
> can be done without help from requests. Was your first explanation
> wrong?

Not quite. I first explain that it can be done WITH help, and then
state that it can be done WITHOUT help. That it can be done with help
does not imply that it cannot be done without help.

Help is nice but it mainly helps for *subsequent* requests; an
external abort might leave internal state somewhat messed up, which
would result in resources not being released until the next query, or
perhaps a query failing and getting retried. But even without help, it
would all work.

ChrisA



More information about the Python-list mailing list