[Tutor] Stopping function after given time

Oliver Maunder 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
> maybe
> >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...
URL: http://mail.python.org/pipermail/tutor/attachments/20051010/40eb4637/attachment.html

More information about the Tutor mailing list