469,281 Members | 2,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

Starting and stopping a background process

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

Jul 18 '05 #1
0 1580

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Paul Hampton | last post: by
reply views Thread by Rafal Zurkowski | last post: by
reply views Thread by tshad | last post: by
8 posts views Thread by cypher543 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.