Our team has been seeing occasional (2006, 'MySQL server has gone away’) errors when trying to make queries during sparse usage.
Normally, it looks like each time a request is started and finished, Django goes through and closes old connections. However, because we are using Django in a standalone script outside of the request context, this signal is not called.
Currently, there are some workarounds, such as wrapping queries in a decorator to run
close_old_connections beforehand. Are there any other suggestions for how to fix this issue?
It seems like this might be a useful functionality built in to Django itself. What do you think people think about automatically calling
close_old_connections lower in the stack, say at the query set level?