mailr14198 - /branches/gui_testing/generic_fns/pipes.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 06, 2011 - 15:20:
Author: bugman
Date: Sat Aug  6 15:20:31 2011
New Revision: 14198

URL: http://svn.gna.org/viewcvs/relax?rev=14198&view=rev
Log:
Most of the data pipe functions are now using the data pipe locking object 
status.pipe_lock.

The functions which acquire the lock object and which modify the pipe state 
include:
    copy()
    create()
    delete()
    switch()

The functions which acquire the lock object to prevent changes while they 
execute include:
    display()
    pipe_loop()


Modified:
    branches/gui_testing/generic_fns/pipes.py

Modified: branches/gui_testing/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/pipes.py?rev=14198&r1=14197&r2=14198&view=diff
==============================================================================
--- branches/gui_testing/generic_fns/pipes.py (original)
+++ branches/gui_testing/generic_fns/pipes.py Sat Aug  6 15:20:31 2011
@@ -54,12 +54,18 @@
     if pipe_to in list(ds.keys()):
         raise RelaxPipeError(pipe_to)
 
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
+
     # The current data pipe.
     if pipe_from == None:
         pipe_from = cdp_name()
 
     # Copy the data.
     ds[pipe_to] = ds[pipe_from].__clone__()
+
+    # Release the lock.
+    status.pipe_lock.release()
 
     # Notify observers that a pipe change has occurred.
     status.observers.pipe_alteration.notify()
@@ -100,8 +106,14 @@
     if pipe_type == 'frame order' and not scipy_module:
         raise RelaxError("The frame order analysis is not available.  Please 
install the scipy Python package.")
 
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
+
     # Add the data pipe.
     ds.add(pipe_name=pipe_name, pipe_type=pipe_type, switch=switch)
+
+    # Release the lock.
+    status.pipe_lock.release()
 
 
 def cdp_name():
@@ -121,6 +133,9 @@
     @type pipe_name:    str
     """
 
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
+
     # Pipe name is supplied.
     if pipe_name != None:
         # Test if the data pipe exists.
@@ -143,12 +158,18 @@
             ds.current_pipe = None
             __builtin__.cdp = None
 
+    # Release the lock.
+    status.pipe_lock.release()
+
     # Notify observers that the switch has occurred.
     status.observers.pipe_alteration.notify()
 
 
 def display():
     """Print the details of all the data pipes."""
+
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
 
     # Heading.
     print(("%-20s%-20s%-20s" % ("Data pipe name", "Data pipe type", 
"Current")))
@@ -163,6 +184,9 @@
         # Print out.
         print("%-20s%-20s%-20s" % ("'"+pipe_name+"'", get_type(pipe_name), 
current))
 
+    # Release the lock.
+    status.pipe_lock.release()
+
 
 def get_pipe(name=None):
     """Return a data pipe.
@@ -228,6 +252,9 @@
     @rtype:         PipeContainer instance or tuple of PipeContainer 
instance and str if name=True
     """
 
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
+
     # Loop over the keys.
     for key in list(ds.keys()):
         # Return the pipe and name.
@@ -238,6 +265,9 @@
         else:
             yield ds[key]
 
+    # Release the lock.
+    status.pipe_lock.release()
+
 
 def pipe_names():
     """Return the list of all data pipes.
@@ -255,6 +285,9 @@
     @param pipe_name:   The name of the data pipe to switch to.
     @type pipe_name:    str
     """
+
+    # Acquire the pipe lock.
+    status.pipe_lock.acquire()
 
     # Test if the data pipe exists.
     test(pipe_name)
@@ -262,6 +295,9 @@
     # Switch the current data pipe.
     ds.current_pipe = pipe_name
     __builtin__.cdp = get_pipe()
+
+    # Release the lock.
+    status.pipe_lock.release()
 
     # Notify observers that the switch has occurred.
     status.observers.pipe_alteration.notify()




Related Messages


Powered by MHonArc, Updated Sat Aug 06 16:20:02 2011