Reputation: 37
Can some one please explain the technicality behind: "DEBUG:snowflake.connector.connection:Rest object has been destroyed, cannot close session"
The following Python was executed successfully:
try:
time_start = pd.Timestamp.now()
connection.execute(SQL)
df = pd.read_sql_query(SQL, engine)
time_end = pd.Timestamp.now()
timer = pd.Timedelta(time_end-time_start).microseconds/1000
print(timer)
except ProgrammingError as e:
if e.errno == 604:
print("timeout")
connection.cursor().execute("rollback")
else:
raise e
else:
connection.cursor().execute("commit")
finally:
connection.close()
engine.dispose()
logging.debug('-------- Finished --------' )
if to_csv:
col_names = df.columns.tolist()
if col_names_upper:
col_names = [x.upper() for x in col_names]
csv_file_name = 'data.csv'
csv_path = os.path.join(dir_path,csv_file_name)
if append:
mode='a'
else:
mode='w'
df.to_csv(csv_path,index=False, mode=mode, header=col_names)
return None
else:
return df.to_dict()
But when I checked the log file, I found the following at the end of the log:
DEBUG:snowflake.connector.network:SUCCESS
DEBUG:snowflake.connector.network:Active requests sessions: 0, idle: 4
DEBUG:snowflake.connector.network:ret[code] = None, after post request
DEBUG:snowflake.connector.connection:Session is closed
DEBUG:root:-------- Finished --------
DEBUG:snowflake.connector.connection:Rest object has been destroyed, cannot close session
DEBUG:snowflake.connector.connection:Rest object has been destroyed, cannot close session
I don't understand what it meant by:"DEBUG:snowflake.connector.connection:Rest object has been destroyed, cannot close session".
Upvotes: 1
Views: 736
Reputation:
The message Rest object has been destroyed, cannot close session
is printed by the Snowflake Python Connector's connection object typically when it is attempted for closure multiple times.
This is normal to observe when using a connection pool manager: The SQLAlchemy-based engine
object will attempt to close all managed connection objects when engine.dispose()
is called), and also due to Python's internal garbage collection that calls connection.__del__()
on objects reaching zero reference counts.
The logger level for the message is intentionally DEBUG to not worry users about successive attempts at connection cleanup by the runtime and frameworks in use. It is safe to ignore this message as it appears after the connection was closed up successfully (indicated via the Session is closed
message preceding it).
Upvotes: 1