On Wed, Aug 23, 2017 at 9:10 PM, Jon Ribbens <jon+use...@unequivocal.eu> wrote:
> On 2017-08-22, Chris Angelico <ros...@gmail.com> wrote:
>> On Wed, Aug 23, 2017 at 5:06 AM, Jon Ribbens <jon+use...@unequivocal.eu> 
>> wrote:
>>> I have no idea what you mean here. The only sane way to implement the
>>> request timeout is to provide both types of timeout.
>>
>> You could provide both, but since one of them can be handled
>> externally (with a thread, with a SIGALRM, or with some other sort of
>> time limiting), the other one MUST be provided by the request.
>
> 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.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to