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. Advertisements

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. chintan jajal via .NET 247

    Delegate Endinvoke Kill thread

    chintan jajal via .NET 247, May 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    7,477
    Richard Grimes [MVP]
    Jun 6, 2005
  2. Rasmus B. Nielsen

    thread kill ?

    Rasmus B. Nielsen, Aug 30, 2003, in forum: Java
    Replies:
    0
    Views:
    583
    Rasmus B. Nielsen
    Aug 30, 2003
  3. bm
    Replies:
    11
    Views:
    6,745
  4. Son KwonNam
    Replies:
    11
    Views:
    2,851
    mr_organic
    Apr 9, 2004
  5. Benji
    Replies:
    34
    Views:
    1,422
    pkriens
    Oct 28, 2005
  6. Jerry Sievers

    thread, threading; how to kill a thread?

    Jerry Sievers, Nov 17, 2004, in forum: Python
    Replies:
    12
    Views:
    1,447
    Mustafa Demirhan
    Nov 19, 2004
  7. 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:
    318
    Poly-poly man
    Aug 24, 2006
  8. Charles Oliver Nutter
    Replies:
    43
    Views:
    948
    Roger Pack
    Mar 25, 2008
Loading...