pyhive is it possible to stop a query job if hit ctrl+c

103 views Asked by At

I uses pyhive in jupyter to connect to hive/presto for some adhoc analysis. Something annoying is if I cancel a submitted query job via 'ctrl + c', it only stops the jupyter, but won't stop the query job remotely. Is there a way, when 'ctrl + c', it also sent a signal to stop the remote job?

def get_data_from_presto(sql):
    conn = presto.connect(...)
    cursor = conn.cursor()
    cursor.execute(sql)
    while cursor.poll() is not None:
        response_json = cursor.poll()
        time.sleep(2)
    col_names = [i[0] for i in cursor.description]
    df = pd.DataFrame(cursor.fetchall(), columns=col_names)
0

There are 0 answers