Acquire the semaphore :param tag: A tag identifying what is acquiring the semaphore. Note that this is not really needed to directly use this class but is needed for API compatibility with the SlidingWindowSemaphore implementation. :param block: I
(self, tag, blocking=True)
| 623 | self._semaphore = threading.Semaphore(count) |
| 624 | |
| 625 | def acquire(self, tag, blocking=True): |
| 626 | """Acquire the semaphore |
| 627 | |
| 628 | :param tag: A tag identifying what is acquiring the semaphore. Note |
| 629 | that this is not really needed to directly use this class but is |
| 630 | needed for API compatibility with the SlidingWindowSemaphore |
| 631 | implementation. |
| 632 | :param block: If True, block until it can be acquired. If False, |
| 633 | do not block and raise an exception if cannot be acquired. |
| 634 | |
| 635 | :returns: A token (can be None) to use when releasing the semaphore |
| 636 | """ |
| 637 | logger.debug("Acquiring %s", tag) |
| 638 | if not self._semaphore.acquire(blocking): |
| 639 | raise NoResourcesAvailable(f"Cannot acquire tag '{tag}'") |
| 640 | |
| 641 | def release(self, tag, acquire_token): |
| 642 | """Release the semaphore |
no test coverage detected