requests.{get,post} timeout

Jon Ribbens jon+usenet at unequivocal.eu
Wed Aug 23 08:52:22 EDT 2017


On 2017-08-23, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Aug 23, 2017 at 9:10 PM, Jon Ribbens <jon+usenet at unequivocal.eu> wrote:
>> I am interested to learn what you mean by "with a thread". How would
>> one execute a requests, er, request in a thread with a proper timeout?
>
> Assuming that by "proper timeout" you mean "limit the entire
> download's wall time": Use one thread to do the request, and another
> thread to monitor it. Generally, the monitoring thread is your UI
> thread (most commonly, the main thread of the program), though it
> doesn't have to be. If the monitoring thread decide that the
> requesting thread has taken too long, it can cut it off and report
> failure to the user.

Yes, what I was interested to learn was how the monitoring thread can
"cut off" the requesting thread.



More information about the Python-list mailing list