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

calling basic_cancel on a closed connection is unsafe #44

Open
GoogleCodeExporter opened this issue Nov 2, 2015 · 0 comments
Open

calling basic_cancel on a closed connection is unsafe #44

GoogleCodeExporter opened this issue Nov 2, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Which version of amqplib are you using?
0.6.1
Have you checked to see if there is a newer version in the "Featured
Downloads" section of the front page of this project?

Yes, but code inspection leads me to believe this is still an issue

Which broker are you using (RabbitMQ?) which version?
yes (rabbit), not sure of version
Which version of Python?
2.7
What steps will reproduce the problem?
1. create a channel
2. start consuming
3. kill rabbit
4. have a basic_cancel in a try:finally: around your consumer loop

What is the expected output? What do you see instead?

I'd expect the basic_cancel to just do nothing on a closed connection (or 
possibly raise an explicit exception).

What we see is captured here:
https://bugs.launchpad.net/python-oops-amqp/+bug/884539
"Traceback (most recent call last):
  File "bin/amqp2disk", line 49, in <module>
    oopstools.scripts.amqp2disk.main()
  File "/srv/lp-oops.canonical.com/cgi-bin/lpoops/src/oopstools/scripts/amqp2disk.py", line 113, in main
    receiver.run_forever()
  File "/srv/lp-oops.canonical.com/cgi-bin/lpoops/eggs/oops_amqp-0.0.3-py2.6.egg/oops_amqp/receiver.py", line 86, in run_forever
    self._run_forever()
  File "/srv/lp-oops.canonical.com/cgi-bin/lpoops/eggs/oops_amqp-0.0.3-py2.6.egg/oops_amqp/receiver.py", line 112, in _run_forever
    self.channel.basic_cancel(self.consume_tag)
  File "/srv/lp-oops.canonical.com/cgi-bin/lpoops/eggs/amqplib-0.6.1-py2.6.egg/amqplib/client_0_8/channel.py", line 1702, in basic_cancel
    self._send_method((60, 30), args)
  File "/srv/lp-oops.canonical.com/cgi-bin/lpoops/eggs/amqplib-0.6.1-py2.6.egg/amqplib/client_0_8/abstract_channel.py", line 69, in _send_method
    self.connection.method_writer.write_method(self.channel_id,
AttributeError: 'NoneType' object has no attribute 'method_writer'
"

Please provide any additional information below.
We've put a if self.channel.is_open: guard around the call to basic_cancel, but 
it would be nice to have fire-and-forget here, as it seems like an obvious 
idiom to be cancelling consumption in a try:finally:

Original issue reported on code.google.com by [email protected] on 1 Nov 2011 at 3:54

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

No branches or pull requests

1 participant