mirror of https://github.com/apache/cassandra
Handle KeyboardInterrupt properly in cqlsh
Patch by Jordon Pittier, reviewed by brandonwilliams for CASSANDRA-5481
This commit is contained in:
parent
192596ad75
commit
249bbfc3b2
20
bin/cqlsh
20
bin/cqlsh
|
|
@ -504,15 +504,9 @@ class Shell(cmd.Cmd):
|
|||
self.conn = use_conn
|
||||
else:
|
||||
transport = transport_factory(hostname, port, os.environ, CONFIG_FILE)
|
||||
self.conn = cql.connect(hostname, port, user=username, password=password,
|
||||
cql_version=cqlver, transport=transport)
|
||||
self.conn = cql.connect(hostname, port, keyspace=keyspace, user=username,
|
||||
password=password, cql_version=cqlver, transport=transport)
|
||||
self.set_expanded_cql_version(cqlver)
|
||||
# we could set the keyspace through cql.connect(), but as of 1.0.10,
|
||||
# it doesn't quote the keyspace for USE :(
|
||||
if keyspace is not None:
|
||||
tempcurs = self.conn.cursor()
|
||||
tempcurs.execute('USE %s;' % self.cql_protect_name(keyspace))
|
||||
tempcurs.close()
|
||||
self.cursor = self.conn.cursor()
|
||||
self.get_connection_versions()
|
||||
|
||||
|
|
@ -1056,6 +1050,16 @@ class Shell(cmd.Cmd):
|
|||
except CQL_ERRORS, err:
|
||||
self.printerr(str(err))
|
||||
return False
|
||||
except KeyboardInterrupt:
|
||||
self.cursor.close()
|
||||
self.conn.terminate_connection()
|
||||
transport = self.transport_factory(self.hostname, self.port,
|
||||
os.environ, CONFIG_FILE)
|
||||
self.conn = cql.connect(self.hostname, self.port, keyspace=self.keyspace,
|
||||
user=self.username, password=self.password,
|
||||
cql_version=self.cql_version, transport=transport)
|
||||
self.cursor = self.conn.cursor()
|
||||
return False
|
||||
except Exception, err:
|
||||
import traceback
|
||||
self.printerr(traceback.format_exc())
|
||||
|
|
|
|||
Loading…
Reference in New Issue