Dynamic Queue in python