I wrote the code, so I guess I should give an answer ;)
MaybeChannelBound is a common base class for
because they both have the same semantics (terrible name, as so often happens
when one tries to use inheritance...)
__call__ was an API decision, so:
returns a queue that is bound to a channel so that you can do operations
on it. I simply thought the call looked better in the API, I don't remember
exactly why I included the .bind method too, but I can guess that
If someone wanted to create a subclass of this, then overriding
bind operation would seem neater than using
When duck-typing it would be rather useless to check for
.bind could be used for this purpose.
In recent Kombu you rarely have to bind the channels yourself, e.g.
when publishing a message you now send a list of entities to declare
Producer.publish instead (and declarations are cached too):
producer = Producer(connection)
producer.publish(message, retry=True, declare=[queue])
where you previously would have to write:
with connection.channel() as channel:
There isn't always any universally good reason for everything I do though,
sometimes I do things just because it is a practice of mine.
Sometimes those practices turns out the useful, other times
they just end up being useless boilerplate.