rocksq.blocking
- class rocksq.blocking.PersistentQueueWithCapacity(path, max_elements=1000000000)
A persistent queue with a fixed capacity. This is a blocking implementation.
- Parameters:
path (str) – The path to the queue.
max_elements (int) – The maximum number of elements the queue can hold. Default is
1_000_000_000
.
- Raises:
PyRuntimeError – If the queue could not be created.
- disk_size
Returns the disk size of the queue in bytes.
- Returns:
size
- Return type:
int
- Raises:
PyRuntimeError – If the method fails.
- is_empty
Checks if the queue is empty.
- Returns:
True
if the queue is empty,False
otherwise.- Return type:
bool
- len
Returns the number of elements in the queue.
- Returns:
The number of elements in the queue.
- Return type:
int
- payload_size
Returns the size of the queue in bytes (only payload).
- Returns:
size
- Return type:
int
- pop(max_elements=1, no_gil=True)
Retrieves items from the queue.
GIL: the method can optionally be called without the GIL.
- Parameters:
max_elements (int) – The maximum number of elements to retrieve. Default is
1
.no_gil (bool) – If True, the method will be called without the GIL. Default is
True
.
- Raises:
PyRuntimeError – If the method fails.
- Returns:
items – The items retrieved from the queue.
- Return type:
list of bytes
- push(items, no_gil=True)
Adds items to the queue.
GIL: the method can optionally be called without the GIL.
- Parameters:
items (list of bytes) – The items to add to the queue.
no_gil (bool) – If True, the method will be called without the GIL. Default is
True
.
- Raises:
PyRuntimeError – If the method fails.
- Return type:
None