threading troubles

Antoon Pardon apardon at forel.vub.ac.be
Wed Jul 12 07:46:05 EDT 2006


On 2006-07-10, sreekant <skodela at lithium.com> wrote:
> Hi folks
>
> What am I doing wrong in the following? I just want to run fluidsynth in 
> the background.
> #########################################
> class MyThread(threading.Thread):
>      def __init__(self, cmd, callback):
>          self.__cmd = cmd
>          self.__callback = callback
>          threading.Thread.__init__(self)
>
>      def run(self):
>          os.system(self.__cmd)
>          self.__callback('abcd')
>          return
>
>
> cmd=midiplay+' '+fmidi
> xc=MyThread(cmd,addlog)
> xc.start()
>
>
> ######################
> midiplay is 'fluidsynth -ni /home/mysndfont.sf2 mymidi.mid'
> addlog is a function which prints the log.
>
> If I run it only with xc.start() it does not run the program as in 
> os.system. However if I  put
> xc.start()
> xc.run()
>
> then it starts and runs it in foreground with my pygtk ui non responsive.
>
> What am I missing!

You may be missing nothing. If I recall correctly a similar problem was
once reported on the pygtk-list. Some investigation showed that some
programs couldn't be reliably run from a thread, using os.system.

-- 
Antoon Pardon



More information about the Python-list mailing list