How to kill/stop a Thread?

Discussion in 'Python' started by Dirk Zimmermann, Mar 22, 2006.

  1. 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
     
    Dirk Zimmermann, Mar 22, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Son KwonNam
    Replies:
    11
    Views:
    2,605
    mr_organic
    Apr 9, 2004
  2. Benji
    Replies:
    34
    Views:
    1,177
    pkriens
    Oct 28, 2005
  3. Jerry Sievers

    thread, threading; how to kill a thread?

    Jerry Sievers, Nov 17, 2004, in forum: Python
    Replies:
    12
    Views:
    1,155
    Mustafa Demirhan
    Nov 19, 2004
  4. Poly-poly man

    Stop an SDL_sound stream, or possibly kill the fork?

    Poly-poly man, Aug 24, 2006, in forum: C Programming
    Replies:
    2
    Views:
    288
    Poly-poly man
    Aug 24, 2006
  5. Charles Oliver Nutter
    Replies:
    43
    Views:
    626
    Roger Pack
    Mar 25, 2008
Loading...

Share This Page