ChunkedSemaphore#
- class maize.utilities.resources.ChunkedSemaphore(max_count: int, sleep: int = 5)[source]#
Bases:
object
Semaphore allowing chunked atomic resource acquisition.
- Parameters:
max_count – Initial value representing the maximum resources
sleep – Time to wait in between semaphore checks
Methods
- acquire(value: int) None [source]#
Acquire resources.
- Parameters:
value – Amount to acquire
- Raises:
ValueError – If the amount requested exceeds the available resources
- release(value: int) None [source]#
Release resources.
- Parameters:
value – Amount to release
- Raises:
ValueError – If the amount released exceeds the available resources