Go to the latest version of this document.

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

class documentation

`class _ConcurrencyPrimitive(ABC): (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: `Self`) -> `Deferred[Self]`: (source)

We can be used as an asynchronous context manager.

def __aexit__(self, __exc_type: `type[BaseException] | None`, __exc_value: `BaseException | None`, __traceback: `TracebackType | None`) -> `Deferred[Literal[False]]`: (source)

Undocumented

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

Undocumented

@abstractmethod
def acquire(self: `Self`) -> `Deferred[Self]`: (source)
overridden in `twisted.internet.defer.DeferredLock`, `twisted.internet.defer.DeferredSemaphore`

Undocumented

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

Undocumented

@overload
def run(self: `Self`, /, f: `Callable[_P, Deferred[_T]]`, *args: `_P.args`, **kwargs: `_P.kwargs`) -> `Deferred[_T]`:
@overload
def run(self: `Self`, /, f: `Callable[_P, Coroutine[Deferred[Any], Any, _T]]`, *args: `_P.args`, **kwargs: `_P.kwargs`) -> `Deferred[_T]`:
@overload
def run(self: `Self`, /, f: `Callable[_P, _T]`, *args: `_P.args`, **kwargs: `_P.kwargs`) -> `Deferred[_T]`:
(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.

Returns
`Deferred[_T]` | `Deferred` of function result.

waiting: `list[Deferred[Self]]` = (source)

Undocumented

def _releaseAndReturn(self, r: `_T`) -> `_T`: (source)

Undocumented