[Tutor] Stopping function after given time

Raduz raduzator at volny.cz
Mon Oct 10 15:27:53 CEST 2005

Hi all
Simple question: Is it possible to stop a running function after certain 
predefined time? 

Right now I have some home-made bash scripts for recording shows from net 
broadcasted ogg stream, that use wget for stream downloading, and two "at" 
jobs - one for first script (which prepares directory it's going to save to, 
dumps info about it's own PID, and execs wget for actual download), second for 
another script (which reads PID info dumped by the first script, uses it to 
kill wget and performs some clean-up tasks). 
I would like to convert this routine to Python using pycurl module, or maybe 
even standard urllib.urlretrieve. Problem is, downloaded file is a stream 
without end, so I have to stop the downloader manually, and I would prefer to 
drop the "two scripts" approach - no more PID saving and process killing. I 
want one clean package, which will start the download, let it run for some 
time, and then stop it correctly. I just don't know how to time the download. 
Can anybody give some sugestions, please? Is the threading way to go? Thanks.


More information about the Tutor mailing list