mongodb driver supports MONGO_CONNECT_TIMEOUT system configuration parameter
mysqdb driver supports MYSQL_CONNECT_TIMEOUT system configuration parameter