Reputation: 1
When I try to retrieve a cursor from a MySQL Connection using .cursor()
from mysql.connector
library for Python3 while the connection is not up (Internet down, for example) it gets completely stuck and hangs for around 16 minutes, before even throwing an exception. Any ideas of what can be done to reduce this delay?
def retrieveCursor(mysqlconnection):
printf("Program started")
try:
printf("Going to retrieve the cursor")
cursor=mysqlconnection.cursor()
except:
printf("Exception raised while retreiving the cursor")
return -1
else:
printf("MySQL cursor retrieved")
return cursor
If Internet is up, the output would be:
Program started
Going to retrieve the cursor
MySQL cursor retrieved
If Internet is down (but was up when the connection was originally established):
Program started
Going to retrieve the cursor
.. nothing for 16 minutes ..
Exception raised while retreiving the cursor
Any ideas of why 16 minutes and how to reduce it? Thanks!!
Upvotes: 0
Views: 345