`ReplQueue.full()` and `ReplPriorityQueue.full()` incorrectly return `True`
for their default unbounded configuration.
Both classes default to `maxsize=0` and describe themselves as having an
interface similar to Python's `Queue`. Their `put()` implementations already
treat `maxsize=0` as unbounded:
```python
if self.__maxsize and len(self.__data) >= self.__maxsize:
return False
However, full() currently uses:
return len(self.__data) == self.__maxsize
Therefore, an empty unbounded queue reports itself as full.
Reproducer
from pysyncobj.batteries import ReplQueue, ReplPriorityQueue
for queue_class in (ReplQueue, ReplPriorityQueue):
q = queue_class() # default maxsize=0
print(queue_class.__name__, "initial full():", q.full())
print("put a:", q.put("a", _doApply=True))
print("put b:", q.put("b", _doApply=True))
print("put c:", q.put("c", _doApply=True))
print(queue_class.__name__, "full() after puts:", q.full())
Actual result
ReplQueue initial full(): True
put a: True
put b: True
put c: True
ReplQueue full() after puts: False
ReplPriorityQueue initial full(): True
put a: True
put b: True
put c: True
ReplPriorityQueue full() after puts: False
Expected result
For maxsize=0, the queues are unbounded, consistent with their put()
implementation and Python's queue.Queue(maxsize=0) convention.
Therefore, full() should always return False for maxsize=0.
The current behavior is contradictory: an empty queue reports that it is full,
but accepts items; after items are added, it reports that it is not full.
Suggested fix
Use a positive-capacity check, consistent with put():
def full(self):
return self.__maxsize > 0 and len(self.__data) >= self.__maxsize
This should be applied to both ReplQueue and ReplPriorityQueue in
pysyncobj/batteries.py.
However, full() currently uses:
Therefore, an empty unbounded queue reports itself as full.
Reproducer
Actual result
Expected result
For maxsize=0, the queues are unbounded, consistent with their put()
implementation and Python's queue.Queue(maxsize=0) convention.
Therefore, full() should always return False for maxsize=0.
The current behavior is contradictory: an empty queue reports that it is full,
but accepts items; after items are added, it reports that it is not full.
Suggested fix
Use a positive-capacity check, consistent with put():
This should be applied to both ReplQueue and ReplPriorityQueue in
pysyncobj/batteries.py.