Skip to content

Commit 133d621

Browse files
SNOW-80651 renamed SnowflakeConnection.safe_to_destroy to something less confusi… (#553)
1 parent 94924c6 commit 133d621

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/snowflake/connector/connection.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def close(self, retry=True):
437437
# close telemetry first, since it needs rest to send remaining data
438438
logger.info('closed')
439439
self._telemetry.close(send_on_close=retry)
440-
if self.safe_to_close():
440+
if self._all_async_queries_finished():
441441
logger.info('No async queries seem to be running, deleting session')
442442
self.rest.delete_session(retry=retry)
443443
else:
@@ -1231,11 +1231,8 @@ def is_an_error(status: QueryStatus) -> bool:
12311231
QueryStatus.BLOCKED,
12321232
)
12331233

1234-
def safe_to_close(self) -> bool:
1235-
"""Checks whether this connection is safe to close.
1236-
1237-
A connection is safe to close if all of its async queries are not running anymore.
1238-
"""
1234+
def _all_async_queries_finished(self) -> bool:
1235+
"""Checks whether all async queries started by this Connection have finished executing."""
12391236
queries = copy.copy(self._async_sfqids) # get_query_status might update _async_sfqids, let's copy the list
12401237
finished_async_queries = (not self.is_still_running(self.get_query_status(q)) for q in queries)
12411238
return all(finished_async_queries)

test/integ/test_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_done_caching(conn_cnx):
134134
assert con.get_query_status(qid2) == QueryStatus.SUCCESS
135135
assert len(con._async_sfqids) == 0
136136
assert len(con._done_async_sfqids) == 2
137-
assert con.safe_to_close()
137+
assert con._all_async_queries_finished()
138138

139139

140140
def test_invalid_uuid_get_status(conn_cnx):

0 commit comments

Comments
 (0)