4 ms·
Hmmmmm shouldn't the Python runtime reap the socket and tidy up in this case?
by alexchamberlain 5y ago
Hmmmmm shouldn't the Python runtime reap the socket and tidy up in this case?
- kevincox 5y agoYes, I think it should eventually if you haven't stashed a reference somewhere. Python has both a reference count and a GC so in simple cases it will often be cleaned up as soon as it goes out of scope but if you create a cycle it may take a while. Relying on the GC to close open sockets is a great way to run out of file descriptors when bursts of work happen.
- levi_n 5y agoThe way the original try/except was structured meant the close() for the socket would never get called, so py-amqp holds onto the reference indefinitely, preventing the garbage collector from doing it's thing.