celery / kombu

Messaging library for Python.
http://kombu.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
2.86k stars 926 forks source link

kombu.Connection base class 'connected' attribute is hardcoded to True #432

Open bmbouter opened 9 years ago

bmbouter commented 9 years ago

Recently I've wanted to use the verify_connection attribute on kombu.Connection. After looking at the code the base class is hardcoded to return True per the code below:

     def verify_connection(self, connection):
         return True

This seems bad because it's not going to give correct information. I've got 2 questions on this:

  1. Is there a way that the base class can return the right thing regardless of what Transport is being used?
  2. If it has do be done at the inherited Transport level, I think the base class should raise a NotImplementedError by default. This would cause anyone using it to realize that the Transport they are using does not implement this correctly and they can plan accordingly.

I suspect the answer to (1) is No, but I hope the answer to (2) is that we should change the default implementation of verify_connection to raise a NotImplementedError.

ask commented 9 years ago

The problem is backwards compatibility. We cannot just raise something here without having a proper deprecation cycle first, otherwise people are likely to only realize when it first crashes in production.

Even if we wait for 4.0 it will be hard to make sure everyone is aware of the change :(