[Qt-interest] multiple QThread simultaneously

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Wed Apr 29 02:50:06 CEST 2009


Hi Rui, 

It is certainly possible to run multiple threads of the same class -
assuming that all of the actions are thread-safe or use appropriate locking.


Regardless of the error you are getting, I think your code will fail anyway,
because 'chdir' is process-wide, not thread specific? 

Tony.

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com 
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of NARCISO, Rui
> Sent: Tuesday, 28 April 2009 23:40
> To: R. Reucher; qt-interest at trolltech.com
> Subject: Re: [Qt-interest] multiple QThread simultaneously
> 
> 
> 
> 
> :p I know you can't _guess_ what's wrong ... before posting 
> any code I wanted to make sure that it was possible "in theory" !!
> 
> Here's the code:
> 
> class DamasToTecplotThread(QThread):
>     def __init__(self, dirList = [] ,rnaFile="", parent=None):
>         QThread.__init__(self, parent)
>         self.parent = parent
>         self.dirList = dirList
>         self.rnaFile = rnaFile
>         
>     def run(self):
> 
>         for dir, item in self.dirList:
>             os.chdir(os.path.dirname(os.path.abspath(dir)))
>             sys.argv = [sys.argv[0]] + ["-dir", dir, "-rna", 
> self.rnaFile]
>             damas2tecplot.run()
>             self.emit(SIGNAL('tecplotConversionLaunched'), 
> "Tecplot Conversion", \
>                       
> os.path.join(os.path.dirname(os.path.abspath(dir)), 
> 'POST_ALL',os.path.basename(os.path.abspath(dir))),  "", item, 10)
> 
> which is called like this:
>                 newThread = DamasToTecplotThread(dir, rnaFile, self)
>                 self.connect(newThread, 
> SIGNAL('tecplotConversionLaunched'), 
> self.addPostToCalculation, Qt.QueuedConnection)
>                 newThread.start()
> 
> and the error I get is:
> Traceback (most recent call last):
>   File 
> "/home/cfdqdv2/to96665/TOOLS/EGADYT/integration/Version_1.0.5/
> CampaignManager/LibThread.py", line 96, in run
>     self.emit(SIGNAL('tecplotConversionLaunched'), "Tecplot 
> Conversion", \
> TypeError: 'NoneType' object is not callable
> 
> any ideas ?





More information about the Qt-interest-old mailing list