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

Function methods should also raise an error if used after closing #62

Open
tvoinarovskyi opened this issue Nov 3, 2015 · 0 comments
Open
Milestone

Comments

@tvoinarovskyi
Copy link
Contributor

The usecase I want to cover is like so:

import asyncio
import asynqp


@asyncio.coroutine
def main_coro(loop):
    # connect to the RabbitMQ broker
    connection = yield from asynqp.connect(
        'localhost', 5672, username='guest', password='guest')

    # Open a communications channel
    channel = yield from connection.open_channel()
    yield from channel.declare_queue('test.queue')
    exchange = yield from channel.declare_exchange("", "direct")

    msg = asynqp.Message({'hello': 'world'})

    yield from channel.close()
    # Expected to raise error!!!
    exchange.publish(msg, 'test.queue')

    yield from connection.close()


def main():
    loop = asyncio.get_event_loop()
    main_task = asyncio.async(main_coro(loop))
    try:
        loop.run_until_complete(main_task)
    except asyncio.CancelledError:
        pass

if __name__ == "__main__":
    main()

Methods, that come to mind:

  • publish
  • ack/reject

Any ideas how to gracefully do it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants