ebin123456 / py-amqplib

Automatically exported from code.google.com/p/py-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Connection _do_close() does not clean up if transport.close() fails #40

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using v1.0.0 of amqplib, Python 2.7.1, Mac OS X 10.7. 

If network connectivity is lost while a Connection is open, and the Connection 
is then closed, its _do_close() method first attempts to close its transport. 
When that fails, an exception is raised, and the rest of the cleanup code in 
_do_close() is not run.  This leaves Channel objects with open callback 
references.  Since the object that created the Connection and Channel is likely 
to provide the callback for that Channel, a circular reference results and the 
objects are never deleted.

I've worked around this problem by wrapping the self.transport.close() call in 
Connection's _do_close in a try: finally block, so the cleanup code is run 
whether the transport.close() works or not. If this is an inappropriate 
solution, or I'm missing something, I'd like to know. Thanks!

Original issue reported on code.google.com by jgarb...@gmail.com on 24 Sep 2011 at 2:08

GoogleCodeExporter commented 9 years ago
Perhaps transport.close() should never be raising an exception?  That would be 
a little cleaner to code.  What's the best way to duplicate this scenario for 
testing?

Original comment by barry.pe...@gmail.com on 28 Sep 2011 at 10:26