Add `connection_closed` or `pre_connection_closed` and `post_connection_closed` signals

Currently I’m facing an issue with stale DB connections. It’s probably related to my setup. Having connection_closed signal would simplify my debugging process.

Since 2009, there’s connection_created signal, added in 6f38697f90a14f1450a71c1e40aea0f5df7dca86 (I can’t post the link because the forum complains about An error occurred: Sorry, new users can only put 2 links in a post.…)

I’d like to create a connection_closed signal and connect it here

This way the connection can be accessed right before closing it.

I’d be happy to implement it. Let me know what you think.

I’m also open to pre_connection_closed and post_connection_closed. Even though not many people will ever use it, I can imagine wanting both in different cases.


initially posted here #36003 (Add `connection_closed` or `pre_connection_closed` and `post_connection_closed` signals) – Django