Yes, the solution will likely include a variable threading.Condition, as you noted in the comments.
Without additional information or a piece of code, it is difficult to understand which API is suitable for your needs. How do you create new elements? How do you consume them? Basically, you can do something like this:
cv = threading.Condition()
elements = []
def produce(...):
with cv:
... add elements somehow ...
cv.notify_all()
def consume(...):
with cv:
while len(elements) == 0:
cv.wait()
... remove elements somehow ...
source
share