Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Private Attributes
_dummy_thread.LockType Class Reference
Inheritance diagram for _dummy_thread.LockType:
Inheritance graph
[legend]
Collaboration diagram for _dummy_thread.LockType:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def acquire
def __exit__
def release
def locked

Public Attributes

 locked_status
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Private Attributes

 __enter__ = acquire

Detailed Description

Class implementing dummy implementation of _thread.LockType.

Compatibility is maintained by maintaining self.locked_status
which is a boolean that stores the state of the lock.  Pickling of
the lock, though, should not be done since if the _thread module is
then used with an unpickled ``lock()`` from here problems could
occur from this class not having atomic methods.

Definition at line 88 of file _dummy_thread.py.


Constructor & Destructor Documentation

Definition at line 99 of file _dummy_thread.py.

00099 
00100     def __init__(self):
00101         self.locked_status = False

Here is the caller graph for this function:


Member Function Documentation

def _dummy_thread.LockType.__exit__ (   self,
  typ,
  val,
  tb 
)

Definition at line 128 of file _dummy_thread.py.

00128 
00129     def __exit__(self, typ, val, tb):
00130         self.release()

Here is the call graph for this function:

Here is the caller graph for this function:

def _dummy_thread.LockType.acquire (   self,
  waitflag = None,
  timeout = -1 
)
Dummy implementation of acquire().

For blocking calls, self.locked_status is automatically set to
True and returned appropriately based on value of
``waitflag``.  If it is non-blocking, then the value is
actually checked and not set if it is already acquired.  This
is all done so that threading.Condition's assert statements
aren't triggered and throw a little fit.

Definition at line 102 of file _dummy_thread.py.

00102 
00103     def acquire(self, waitflag=None, timeout=-1):
00104         """Dummy implementation of acquire().
00105 
00106         For blocking calls, self.locked_status is automatically set to
00107         True and returned appropriately based on value of
00108         ``waitflag``.  If it is non-blocking, then the value is
00109         actually checked and not set if it is already acquired.  This
00110         is all done so that threading.Condition's assert statements
00111         aren't triggered and throw a little fit.
00112 
00113         """
00114         if waitflag is None or waitflag:
00115             self.locked_status = True
00116             return True
00117         else:
00118             if not self.locked_status:
00119                 self.locked_status = True
00120                 return True
00121             else:
00122                 if timeout > 0:
00123                     import time
00124                     time.sleep(timeout)
00125                 return False

Here is the caller graph for this function:

Definition at line 140 of file _dummy_thread.py.

00140 
00141     def locked(self):
00142         return self.locked_status
00143 
# Used to signal that interrupt_main was called in a "thread"
Release the dummy lock.

Definition at line 131 of file _dummy_thread.py.

00131 
00132     def release(self):
00133         """Release the dummy lock."""
00134         # XXX Perhaps shouldn't actually bother to test?  Could lead
00135         #     to problems for complex, threaded code.
00136         if not self.locked_status:
00137             raise error
00138         self.locked_status = False
00139         return True

Here is the caller graph for this function:


Member Data Documentation

Definition at line 126 of file _dummy_thread.py.

Definition at line 100 of file _dummy_thread.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: