Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error callback is called after channel is "legally" closed #117

Open
kr41 opened this issue Nov 10, 2016 · 0 comments
Open

Error callback is called after channel is "legally" closed #117

kr41 opened this issue Nov 10, 2016 · 0 comments
Labels

Comments

@kr41
Copy link

kr41 commented Nov 10, 2016

I use on_error parameter of aioamqp.connect to pass handler, which reestablish connection when it is accidentally closed. But it is called even after the channel is "legally" closed, which definitely is not an error case. And its exception argument looks weird: ChannelClosed(ChannelClosed(None, None), 'Channel is closed').

Here is the code to reproduce the issue:

import logging
import asyncio
import aioamqp


logger = logging.getLogger(__name__)


def on_error(exc):
    logger.error('Handle error %r', exc)


async def run(loop):
    transport, protocol = await aioamqp.connect(on_error=on_error, loop=loop)
    channel = await protocol.channel()

    logger.info('Close channel')
    await channel.close()
    logger.info('Close protocol')
    await protocol.close()
    logger.info('Close transport')
    transport.close()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop=loop))

Here is its output:

DEBUG:asyncio:Using selector: EpollSelector
INFO:aioamqp.protocol:Recv open ok
DEBUG:aioamqp.channel:Channel is open
INFO:__main__:Close channel
INFO:aioamqp.channel:Channel closed
INFO:__main__:Close protocol
INFO:aioamqp.protocol:Recv close ok
INFO:__main__:Close transport
WARNING:aioamqp.protocol:Connection lost exc=None
ERROR:__main__:Handle error ChannelClosed(ChannelClosed(None, None), 'Channel is closed')

Environment:

  • Python 3.5.2
  • aioamqp 0.8.2
  • CentOS Linux release 7.2.1511 (Core)
@dzen dzen added the bug label Nov 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants