Starting and stopping a background process

Discussion in 'Python' started by Paul Hampton, Jul 3, 2003.

  1. Paul Hampton

    Paul Hampton Guest

    Hi all

    I'm new to python so please be gentle :)

    I'm trying to write a module for my media playing PC which will record
    input directly from the soundcard using LAME. At the moment I can get it
    started ok and am about to try and work out the best way to stop the
    process (which is threaded). I could get the process id of LAME and just
    kill it, but I think this is a bit messy. Can anyone give me any
    suggestions on how to make this script determine if lame is already
    running and then stop it if it is, if not then start it? The following
    code is run when a certain key is pressed:

    class main_recording_thread(threading.Thread):


    def __init__(self):
    threading.Thread.__init__(self)


    def run(self):
    self.recording_threaded()


    def recording_threaded(self):
    popup_string="Recording Audio Stream"
    pop = PopupBox(text=popup_string)
    pop.show()
    time.sleep(4)
    pop.destroy()
    print "Recording"
    time.sleep(20)
    recording=1
    os.system("sox -t ossdsp -w -s -r 44100 -c 2 /dev/dsp -t raw -
    | /usr/local/freevo/runtime/apps/lame -x -m s - ./test.mp3")
    popup_string="Audio Recording Stopped"
    pop = PopupBox(text=popup_string)
    pop.show()
    time.sleep(4)
    pop.destroy()
    print "Recording Stopped"
    recording=0
    return []

    I expect my coding is really bad as it is my second attempt ever at python.

    So, what would be the best way to do this start/stop thing?

    Thanks in advance
    Paul
    Paul Hampton, Jul 3, 2003
    #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. Miguel De Anda
    Replies:
    3
    Views:
    11,201
    Ivan S Kirkpatrick
    Jul 3, 2003
  2. Rhino
    Replies:
    0
    Views:
    1,465
    Rhino
    Nov 15, 2003
  3. dfaber
    Replies:
    1
    Views:
    355
    Amit Khemka
    Jul 4, 2006
  4. -intl.com
    Replies:
    1
    Views:
    356
    Martin Gregorie
    Oct 22, 2006
  5. DevNull
    Replies:
    3
    Views:
    416
Loading...

Share This Page