473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 1657

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul Hampton | last post by:
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...
0
by: Rafal Zurkowski | last post by:
Hello everybody, Maybe my question is very simple but I can't find answer for it. And without it I can't go on. I have installed SQL 2000 Personal edition on Windows 98. All the setup process ran...
0
by: tshad | last post by:
I have a Windows Service I created that just sets a timer and writes to EventLog every 10 seconds. It installed fine and it actually starts. But it says it doesn't. The progress bar shows the...
1
by: juleni | last post by:
Hello, is there a possibility starting or stopping postgres database and creating database instance by JAVA? Is there some API available for this? If yes, can you please write some example, how...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: dfaber | last post by:
Aloha! I want to terminate a process/program from within a python script. For example, if I have a program say foo.sh that starts running, then I can run it from within a python script using...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
8
by: cypher543 | last post by:
This has been driving me insane for the last hour or so. I have search everywhere, and nothing works. I am trying to use the subprocess module to run a program and get its output line by line. But,...
7
by: tim | last post by:
Hi all, I want to execute a VB application from a ASP page (not .Net). Want I want to do is that I write some parameters to a database and then start the external application that will pickup...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.