How to kill/stop a Thread?

Dirk Zimmermann python-list at d1z1.de
Wed Mar 22 03:20:14 EST 2006


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






More information about the Python-list mailing list