[prev in list] [next in list] [prev in thread] [next in thread] 

List:       relax-devel
Subject:    Re: r11079 - /branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py
From:       Michael Bieri <michael.bieri () domain ! hid>
Date:       2010-04-14 22:19:30
Message-ID: 4BC63F72.9080403 () domain ! hid
[Download RAW message or body]

This does not work in either the thread or threading module. I tried 
both and this seems to be the simplest solution.
 

Edward d'Auvergne wrote:
> You could then just use:
> 
> id = thread.start_new_thread(self.execute_thread, ())
> 
> and remove the argument from self.execute_thread.  This should then
> work.  This seems to be related to the low-level nature of the thread
> class "this module provides low-level primitives for working with
> multiple threads".  The word low-level is, in programming speak, a
> strong warning!  I think that because the Python hard-core programming
> elite recommend the following about the thread package
> (http://docs.python.org/library/thread.html):
> 
> "... you should consider using the high-level threading module instead."
> 
> and:
> 
> "The threading module provides an easier to use and higher-level
> threading API built on top of this module."
> 
> Not only that, but 'thread' is not supported on all computer systems
> but 'threading' is - "For systems lacking the thread module, the
> dummy_thread module is available.".  Therefore I would consider it
> very unwise to not switch from the 'thread' module to the 'threading'
> module.
> 
> Regards,
> 
> Edward
> 
> 
> 
> On 14 April 2010 00:33, Michael Bieri <michael.bieri@domain.hid> wrote:
> 
> > The dummy_string is added as thread.start_new_thread needs two arguments. If
> > we call execute_thread() function as self.execute_thread(), we cannot create
> > a tuple, which is necessary in the second argument. Therefore, I created the
> > dummy_string. This allows to add a tuple as second argument. Not ideal...
> > but works.
> > 
> > Edward d'Auvergne wrote:
> > 
> > > This is fair enough.  But what is the purpose of dummy_string?
> > > 
> > > Cheers,
> > > 
> > > Edward
> > > 
> > > 
> > > On 13 April 2010 07:01,  <michael.bieri@domain.hid> wrote:
> > > 
> > > 
> > > > Author: michaelbieri
> > > > Date: Tue Apr 13 07:01:28 2010
> > > > New Revision: 11079
> > > > 
> > > > URL: http://svn.gna.org/viewcvs/relax?rev=11079&view=rev
> > > > Log:
> > > > Storage of thread id is removed from auto_rx_base.py as it is unused
> > > > (threads can't get killed).
> > > > 
> > > > Modified:
> > > > branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py
> > > > 
> > > > Modified: branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py
> > > > URL:
> > > > http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py?rev=11079&r1=11078&r2=11079&view=diff
> > > >  
> > > > ==============================================================================
> > > >                 
> > > > --- branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py (original)
> > > > +++ branches/bieri_gui/gui_bieri/analyses/auto_rx_base.py Tue Apr 13
> > > > 07:01:28 2010
> > > > @@ -363,27 +363,14 @@
> > > > # Display the relax controller.
> > > > self.gui.controller.Show()
> > > > 
> > > > -        # FIXME:  Debugging code, non-threaded exec.
> > > > -        self.execute_thread()
> > > > -        event.Skip()
> > > > -        return
> > > > -
> > > > -        # The thread object storage.
> > > > -        self.gui.calc_threads.append(Thread_container())
> > > > -        thread_cont = self.gui.calc_threads[-1]
> > > > -
> > > > # Start the thread.
> > > > -        id = thread.start_new_thread(self.execute_thread, ())
> > > > -
> > > > -        # Add the thread info to the container.
> > > > -        thread_cont.id = id
> > > > -        thread_cont.analysis_type = self.analysis_type
> > > > +        id = thread.start_new_thread(self.execute_thread, ('dummy',))
> > > > 
> > > > # Terminate the event.
> > > > event.Skip()
> > > > 
> > > > 
> > > > -    def execute_thread(self):
> > > > +    def execute_thread(self, dummy_string):
> > > > """Execute the calculation in a thread."""
> > > > 
> > > > # Redirect relax output and errors to the controller.
> > > > 
> > > > 
> > > > _______________________________________________
> > > > relax (http://nmr-relax.com)
> > > > 
> > > > This is the relax-commits mailing list
> > > > relax-commits@domain.hid
> > > > 
> > > > To unsubscribe from this list, get a password
> > > > reminder, or change your subscription options,
> > > > visit the list information page at
> > > > https://mail.gna.org/listinfo/relax-commits
> > > > 
> > > > 
> > > > 
> > > _______________________________________________
> > > relax (http://nmr-relax.com)
> > > 
> > > This is the relax-devel mailing list
> > > relax-devel@domain.hid
> > > 
> > > To unsubscribe from this list, get a password
> > > reminder, or change your subscription options,
> > > visit the list information page at
> > > https://mail.gna.org/listinfo/relax-devel
> > > 
> > > 
> > > 
> > > 
> 
> 
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic