mailr11820 - /1.3/status.py


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

Header


Content

Posted by edward on December 14, 2010 - 23:47:
Author: bugman
Date: Tue Dec 14 23:47:05 2010
New Revision: 11820

URL: http://svn.gna.org/viewcvs/relax?rev=11820&view=rev
Log:
An execution lock has been added to the status object.

This allows parts of relax to prevent others from running, which is 
especially useful in certain
UIs.  A special Exec_lock class object has been created to simulate a proper 
threading.Lock object,
but with certain additional features.


Modified:
    1.3/status.py

Modified: 1.3/status.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/status.py?rev=11820&r1=11819&r2=11820&view=diff
==============================================================================
--- 1.3/status.py (original)
+++ 1.3/status.py Tue Dec 14 23:47:05 2010
@@ -23,6 +23,11 @@
 # Module docstring.
 """Module containing the status singleton object."""
 
+# Python module imports.
+from threading import Lock
+
+# relax module imports.
+from relax_errors import RelaxError
 
 
 class Status(object):
@@ -33,6 +38,9 @@
 
     def __init__(self):
         """Initialise all the status data structures."""
+
+        # Execution lock object.
+        self.exec_lock = Exec_lock()
 
         # The Monte Carlo simulation status.
         self.mc_number = None
@@ -59,5 +67,51 @@
         return self._instance
 
 
+
 class Status_container:
     """The generic empty container for the status data."""
+
+
+
+class Exec_lock:
+    """A type of locking object for locking execution of relax."""
+
+    def __init__(self):
+        """Set up the lock-like object."""
+
+        # Init a threading.Lock object.
+        self._lock = Lock()
+
+        # The name of the locker.
+        self._name = None
+
+
+    def acquire(self, name):
+        """Simulate the Lock.acquire() mechanism.
+
+        @param name:    The name of the locking code.
+        @type name:     str
+        """
+
+        # Store the name.
+        self._name = name
+
+        # Acquire the real lock.
+        return self._lock.acquire()
+
+
+    def locked(self):
+        """Simulate the Lock.locked() mechanism."""
+
+        # Call the real method.
+        return self._lock.locked()
+
+
+    def release(self):
+        """Simulate the Lock.release() mechanism."""
+
+        # Reset the name.
+        self._name = None
+
+        # Release the real lock.
+        return self._lock.release()




Related Messages


Powered by MHonArc, Updated Wed Dec 15 00:00:02 2010