SNOW-1062439: Automatically closing sessions and connections using Python with
leads to errors when deploying to stored procedures
#1259
Labels
feature
New feature or request
When creating a session I am using the Python
with
statement in order to automatically close the connection and remove the session.What is the current behavior?
Currently using the
with
statement to automatically close connections when running in Stored Procedures or Snowflake Streamlit apps throws an error due to closing the connection not being allowed in stored procedures.snowpark-python/src/snowflake/snowpark/session.py
Lines 492 to 495 in 2d88994
This leads to the code having to be different when running locally or in stored procedures.
What is the desired behavior?
Ideally I would like the same Python code to run locally as well as in stored procedures or Streamlit apps.
How would this improve
snowflake-snowpark-python
?This would make it easier to develop locally and then moving deployments to Snowflake, for example in the form of Streamlit Apps.
Possible Solution
Instead of throwing an error a warning could be logged and when detecting that code is running inside a stored procedure the session is not closed, ignoring the
with
functionality.The text was updated successfully, but these errors were encountered: