celery / kombu

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

Autoretry errback is not triggered #921

Open mcdoker18 opened 5 years ago

mcdoker18 commented 5 years ago

Hi! Test case:

  1. Stop the RabbitMQ server
  2. Execute the following script
def on_error(exc, interval):
    print('error')

def on_reconnection(new_channel):
    print('reconnected')

def execute_method(channel):
    print('execute method')

if __name__ == '__main__':
    from kombu import Connection

    conn = Connection('amqp://guest:guest@localhost:5672//')
    autoretry_method = conn.autoretry(execute_method, channel=None,
                                      max_retries=None,
                                      errback=on_error,
                                      interval_start=1,
                                      interval_step=1,
                                      interval_max=30,
                                      on_revive=on_reconnection)
    ret, channel = autoretry_method()

Expected: "error" message printed in the console

Actual: Console is empty

If I check out the v4.0.1 tag then the script runs properly. I guess the problem appeared after this commit https://github.com/celery/kombu/commit/816e3dcf346decd4d458e2a088ac7a914b48dcce https://github.com/celery/kombu/blob/942a6daba91be2b29863417739c5fcf3511250b8/kombu/connection.py#L509 doesn't propagate errback to the https://github.com/celery/kombu/blob/942a6daba91be2b29863417739c5fcf3511250b8/kombu/connection.py#L417 here https://github.com/celery/kombu/blob/942a6daba91be2b29863417739c5fcf3511250b8/kombu/connection.py#L851

auvipy commented 4 years ago

can you send your suggested improvements?