Reputation: 1381
I'm using MySQLdb
in python to connect to a remote database and execute a query. So far so good. However, it's possible that, for any number of reasons, there simply isn't a MySQL server (or indeed any server) at the designated IP address. In these cases, at the moment MySQLdb
hangs indefinitely. This isn't ideal, I'd prefer to be able to set a timeout which if exceeded would allow me to raise and exception and get on with my life.
Is there a simple way to do this?
Upvotes: 8
Views: 12678