[Tutor] Stopping function after given time
mail at olivermaunder.co.uk
Mon Oct 10 20:10:56 CEST 2005
> >Simple question: Is it possible to stop a running function after certain
> >predefined time?
> >I would like to convert this routine to Python using pycurl module, or
> >even standard urllib.urlretrieve.
If you use urllib.urlretrieve, you can pass in a callback function that gets
called after every few blocks are downloaded. In that function, you could
check how much time has passed since the download started, and quit the
download if necessary. You should be able to do this without threads. I'm
not sure how you stop a download once it's started though!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor