def acquire(self):
        """
        Attempt to acquire the token.

        @return: a L{Deferred} which fires on token acquisition.
        """
        assert self.tokens >= 0, "Internal inconsistency??  tokens should never be negative"
        d = Deferred(canceller=self._cancelAcquire)
        if not self.tokens:
            self.waiting.append(d)
        else:
            self.tokens = self.tokens - 1
            d.callback(self)
        return d

        Attempt to acquire the token.

        @return: a L{Deferred} which fires on token acquisition.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/defer.py