Given the following Python code:
# Use impyla package to access Impala
from impala.dbapi import connect
import logging
def process():
conn = connect(host=host, port=port) # Mocking host and port
try:
cursor = conn.cursor()
# Execute query and fetch result
except:
loggin.error("Task failed with some exception")
finally:
cursor.close() # Exception here!
conn.close()
The connection to Impala was created. But there was an exception in cursor.close()
due to Impala timeout.
What is the proper way to close the cursor
and conn
given the latent exception?