[Tutor] how to set time limit before downloading file

kulibin da-da! kylibine at gmail.com
Thu Aug 24 15:36:53 CEST 2006


Thanks for your help, Kent - everything is working now :)

> > I had to download some files.
> >
> >  Using the code below I could download almost all I had to download, but I
> >  have a problem with 'http://18wheels.wz.cz/csszengarden/back-con.jpg'
> >
> > And the problem is that the script sleeps for some hours. And thats
> > all - no data is read.
> >
> >  Can you show me what is wrong and
> > 1. how to set time for file downloading after what it will ignore this
> > file and start working with next file.
> >
> In your loop you could keep track of the total download time and abort
> if it is too long. See time.time().
> > 2. how to set time for every "d = r.read(1024)" after what script will
> > ignore this file and start working with next file.
> >
> Try calling socket.setdefaulttimeout() before any of your network
> operations start.


More information about the Tutor mailing list