pika/pika — pull request #372 by prantaaho (2013-07-03 10:49:51+00:00)
Title: Fix memory leak with Channel._cancelled-list

Channel object stores used consumer tags to _channel-list when basic_cancel is called and checks that new consumer_tag is not in that list when basic_consume is called. Items from _cancelled-list are never removed, thus the list is ever increasing. In our use case we call basic_consume/basic_cancel repeatedly to poll multiple queues (in order to emulate task priorities) and thus the list grows rapidly.

The pull-request changes the Channel._cancelled to be deque of size 10 and changes the automatic consumer_tag creation to use uuid to guarantee uniqueness.

I was not able to figure out why the used consumer tags were stored permanently in the first place, and thus the deque with arbitrary small size. Would it be enough to pop ctag from the list at _on_cancelok()?