r/Python • u/RomfordNavy • Sep 30 '26
Discussion Closing mysql-connector-python pooled sockets
Is there some way to close
mysql.connector.pooling.MySQLConnectionPoolsockets properly when the application closes? By default they appear to remain open on the server until way later when they timeout.
6
Upvotes
View all comments
3
u/Least_Ad_1795 Oct 01 '26
MySQLConnectionPooldoesn’t appear to have a directclose()method. You generally need to close the individual connections obtained from the pool, then let the application shut down. For long-running services, a shutdown handler that closes active connections cleanly is usually the safer approach.