From b7567797d6dfe9f34ae00e01c04a416208d54913 Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Wed, 11 Oct 2023 14:53:48 +0300 Subject: [PATCH] add connect_timeout inside `set_keyspace_blocking` `set_keyspace_blocking` is called from places holding a lock, and in case that the connection is closed from the server side, it might hang forever. using the `connect_timeout` on it to make sure it won't hang forever. Ref: https://github.com/scylladb/scylladb/issues/15661 --- cassandra/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cassandra/connection.py b/cassandra/connection.py index 295066694b..145e2ff25d 100644 --- a/cassandra/connection.py +++ b/cassandra/connection.py @@ -1509,7 +1509,7 @@ def set_keyspace_blocking(self, keyspace): query = QueryMessage(query='USE "%s"' % (keyspace,), consistency_level=ConsistencyLevel.ONE) try: - result = self.wait_for_response(query) + result = self.wait_for_response(query, timeout=self.connect_timeout) except InvalidRequestException as ire: # the keyspace probably doesn't exist raise ire.to_exception()