# ``twisted`.`internet`.`defer`.`_ConcurrencyPrimitive``

class documentation

`class _ConcurrencyPrimitive(ABC, Generic[_DeferredResultT]): (source)`

Known subclasses: `twisted.internet.defer.DeferredLock`, `twisted.internet.defer.DeferredSemaphore`

View In Hierarchy

Undocumented

Method | `__aenter__` | We can be used as an asynchronous context manager.
Method | `__aexit__` | Undocumented
Method | `__init__` | Undocumented
Method | `acquire` | Undocumented
Method | `release` | Undocumented
Method | `run` | Acquire, run, release.
Instance Variable | `waiting` | Undocumented
Method | `_releaseAndReturn` | Undocumented

def __aenter__(self): (source)
We can be used as an asynchronous context manager.

Returns
`Deferred[_ConcurrencyPrimitiveT]` | Undocumented

def __aexit__(self, exc_type, exc_val, exc_tb): (source)

Undocumented

Parameters
exc_type:`bool` | Undocumented
exc_val:`bool` | Undocumented
exc_tb:`bool` | Undocumented
Returns
`Deferred[bool]` | Undocumented

def __init__(self): (source)
overridden in `twisted.internet.defer.DeferredSemaphore`

Undocumented

@abstractmethod
def acquire(self): (source)
overridden in `twisted.internet.defer.DeferredLock`, `twisted.internet.defer.DeferredSemaphore`

Undocumented

Returns
`Deferred[_ConcurrencyPrimitiveT]` | Undocumented

@abstractmethod
def release(self): (source)
overridden in `twisted.internet.defer.DeferredLock`, `twisted.internet.defer.DeferredSemaphore`

Undocumented

def run(self_319AA2A8B18F4B8EA296D75F279EB07F, f, *args, **kwargs): (source)

Acquire, run, release.

This method takes a callable as its first argument and any number of other positional and keyword arguments. When the lock or semaphore is acquired, the callable will be invoked with those arguments.

The callable may return a `Deferred`; if it does, the lock or semaphore won't be released until that `Deferred` fires.

Parameters
self_319AA2A8B18F4B8EA296D75F279EB07F:`_ConcurrencyPrimitiveT` | Undocumented
f:`Callable[..., _DeferredResultT]` | Undocumented
*args:`object` | Undocumented
**kwargs:`object` | Undocumented
Returns
`Deferred[_DeferredResultT]` | `Deferred` of function result.

waiting: `List[Deferred[_ConcurrencyPrimitiveT]]` = (source)

Undocumented

def _releaseAndReturn(self, r): (source)

Undocumented

Parameters
r:`_T` | Undocumented
Returns
`_T` | Undocumented