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

__init__(max_count: int, sleep: int = 5) None[source]#

Methods

__init__(max_count[, sleep])

acquire(value)

Acquire resources.

release(value)

Release resources.

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