Back to index

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

List of all members.

Public Member Functions

def __init__
def release
def acquire
def __exit__

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Attributes

 _initial_value

Detailed Description

Semaphore that checks that # releases is <= # acquires

Definition at line 370 of file threading.py.


Constructor & Destructor Documentation

def threading._BoundedSemaphore.__init__ (   self,
  value = 1,
  verbose = None 
)

Reimplemented from threading._Semaphore.

Definition at line 372 of file threading.py.

00372 
00373     def __init__(self, value=1, verbose=None):
00374         _Semaphore.__init__(self, value, verbose)
00375         self._initial_value = value

Here is the caller graph for this function:


Member Function Documentation

def threading._Semaphore.__exit__ (   self,
  t,
  v,
  tb 
) [inherited]

Definition at line 363 of file threading.py.

00363 
00364     def __exit__(self, t, v, tb):
00365         self.release()
00366 

Here is the call graph for this function:

def threading._Semaphore.acquire (   self,
  blocking = True,
  timeout = None 
) [inherited]

Definition at line 323 of file threading.py.

00323 
00324     def acquire(self, blocking=True, timeout=None):
00325         if not blocking and timeout is not None:
00326             raise ValueError("can't specify timeout for non-blocking acquire")
00327         rc = False
00328         endtime = None
00329         self._cond.acquire()
00330         while self._value == 0:
00331             if not blocking:
00332                 break
00333             if __debug__:
00334                 self._note("%s.acquire(%s): blocked waiting, value=%s",
00335                            self, blocking, self._value)
00336             if timeout is not None:
00337                 if endtime is None:
00338                     endtime = _time() + timeout
00339                 else:
00340                     timeout = endtime - _time()
00341                     if timeout <= 0:
00342                         break
00343             self._cond.wait(timeout)
00344         else:
00345             self._value = self._value - 1
00346             if __debug__:
00347                 self._note("%s.acquire: success, value=%s",
00348                            self, self._value)
00349             rc = True
00350         self._cond.release()
00351         return rc

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from threading._Semaphore.

Definition at line 376 of file threading.py.

00376 
00377     def release(self):
00378         if self._value >= self._initial_value:
00379             raise ValueError("Semaphore released too many times")
00380         return _Semaphore.release(self)
00381 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 374 of file threading.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: