Author: bugman Date: Thu Dec 16 15:19:14 2010 New Revision: 11844 URL: http://svn.gna.org/viewcvs/relax?rev=11844&view=rev Log: Better locking support for nested scripts. The execution lock directly handles the locking of the nesting of scripts. Modified: 1.3/prompt/interpreter.py 1.3/status.py Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=11844&r1=11843&r2=11844&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Thu Dec 16 15:19:14 2010 @@ -326,11 +326,6 @@ orig_intro_state = self._exec_info.intro self._exec_info.intro = True - # Unlock if necessary. - status = Status() - if status.exec_lock.locked(): - status.exec_lock.release() - # Execute the script. run_script(local=self._locals, script_file=file, quit=quit) @@ -356,8 +351,7 @@ # Execution lock. status = Status() - if not (status.exec_lock.locked() and status.exec_lock._name == 'script UI'): - status.exec_lock.acquire('script UI') + status.exec_lock.acquire('script UI') # The module path. head, tail = path.split(name) @@ -371,8 +365,7 @@ runpy.run_module(module, globals) # Unlock execution if needed. - if status.exec_lock.locked(): - status.exec_lock.release() + status.exec_lock.release() def interact_prompt(self, intro=None, local={}): @@ -489,9 +482,6 @@ # The script failed. exec_pass = False - # Unlock execution. - status.exec_lock.release() - # Catch the RelaxErrors. except AllRelaxErrors, instance: # Unlock execution. Modified: 1.3/status.py URL: http://svn.gna.org/viewcvs/relax/1.3/status.py?rev=11844&r1=11843&r2=11844&view=diff ============================================================================== --- 1.3/status.py (original) +++ 1.3/status.py Thu Dec 16 15:19:14 2010 @@ -86,6 +86,9 @@ # The name of the locker. self._name = None + # Script nesting level. + self._script_nest = 0 + # Debugging. if __main__.debug: self.log = open('lock.log', 'w') @@ -98,13 +101,18 @@ @type name: str """ - # Store the name. - self._name = name - # Debugging. if __main__.debug: self.log.write("Acquired by %s\n" % self._name) return + + # Do not acquire if lunching a script from a script. + if name == 'script UI' and self._name == 'script UI' and self._lock.locked(): + self._script_nest += 1 + return + + # Store the new name. + self._name = name # Acquire the real lock. return self._lock.acquire() @@ -135,5 +143,13 @@ self.log.write("%s\n\n" % text) return + # Nested scripting. + if self._script_nest: + # Decrement. + self._script_nest -= 1 + + # Return without releasing the lock. + return + # Release the real lock. return self._lock.release()