Do:
con.query('SET GLOBAL connect_timeout=28800')
con.query('SET GLOBAL interactive_timeout=28800')
con.query('SET GLOBAL wait_timeout=28800')
Parameter meaning (taken from MySQL Workbench in Navigator: Instance > Options File > Tab "Networking" > Section "Timeout Settings")
- connect_timeout: Number of seconds the mysqld server waits for a connect packet before responding with 'Bad handshake'
- interactive_timeout Number of seconds the server waits for activity on an interactive connection before closing it
- wait_timeout Number of seconds the server waits for activity on a connection before closing it
BTW: 28800 seconds are 8 hours, so for a 10 hour execution time these values should be actually higher.