How to kill/stop a Thread?

D

Dirk Zimmermann

Hi,

I like to do the following: Via http I get a stream of data and I like
to store this data with a python program. So what I need is to start the
downloading and to stop it after a given time. My aproach was to use:
urllib.urlretrieve("ULR","FILENAME")

It is fine! But how to stop the retrieving? Because it is a constant
stream of data there is no natural end. So I thought I use
treading.Thread to do it:

def retr():
urllib.urlretrieve("URL","FILENAME")

t=threading.Thread(target=retr)
t.start()

It's fine! The data is downloaded and I'm back in my program to do some
other stuff. BUT: I cannot stop the download. How can I achieve this?
(Another way of solution (w/o threading) would also helpful, of course!)


Thanks for your help,
Dirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top