Producer-consumer pattern in python