Handle timeouts while connecting to cassandra

I have been recently playing with Cassandra a lot using Python cassandra client.

One issue I saw a lot while timeouts connecting cassandra. The default timeout set in the client library is 5 seconds and it isn’t very intuitive how to increase it.

from cassandra.cluster import Cluster
from cassandra.cluster import ExecutionProfile
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import EXEC_PROFILE_DEFAULT

auth_provider = PlainTextAuthProvider(username='username', password='password')
profile = ExecutionProfile(request_timeout=60)
cluster = Cluster(
    execution_profiles={EXEC_PROFILE_DEFAULT: profile},
session = cluster.connect("database")

The above coode snippet increases the connect timeout and request timeout to 120 and seconds respectively.