im having trouble trying to run more than one applications from my program. I thought threading might help (but actually i hav little knowledge bout it).

below is some part of the program:

if 'pdf' in self.ebook:
                thread.start_new_thread(self.open_pdf())
elif "chm" in self.ebook:
                thread.start_new_thread(self.open_chm())

def open_pdf(self):
        os.system('evince \'%s\''%self.ebook)
    
def open_chm(self):
        os.system('gnochm \'%s\''%self.ebook)

well, the program did run evince (pdf reader), but i cant run another evince. I hav to close the previous one.

What i want is to run more than one ebook.

Please help me here. Tanx 4 all the help

PS. sory my english...not native speaker

Its strange that you can't run another evince. You could get the results of the commands like this

from commands import getstatusoutput
def open_pdf(self):
        status, output = getstatusoutput('evince \'%s\''%self.ebook)
        if status:
                print "evince failed with status %d" % status
                print output
        else:
                print "evince terminated successfully"

It may show you why the second start of evince failed :)

I found a more serious problem, you must not call the function when you use start_new_thread . You should write start_new_thread(self.open_pdf)

also, which version of Python is this? If you are using the latest you should be using the subprocess module as it's much more efficient and easier to use than the old threading module, which is why it's becoming the new standard ;)

You do want threading (note the "ing"), not subprocessing which is used to run a single instance. This link is to Doug Hellman's examples which are excellent. http://blog.doughellmann.com/2008/01/pymotw-threading_13.html The other choice would be to use pyprocessing http://pyprocessing.berlios.de/doc/intro.html There is also fork and spawn but threading or pyprocessing are preferrable as they can do more. Learn one of these, whichever appeals to you the most, and that should be enough for most programs.

This article has been dead for over six months. Start a new discussion instead.