Skip to content

Commit 302ad9c

Browse files
committed
Reset g_session and g_session_path, cleanup on closing :memory:
1 parent a85777d commit 302ad9c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

chdb/session/state.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, path=None):
5151
)
5252
g_session.close()
5353
g_session_path = None
54-
if path is None:
54+
if path is None or ":memory:" in path:
5555
self._cleanup = True
5656
self._path = tempfile.mkdtemp()
5757
else:
@@ -89,13 +89,19 @@ def close(self):
8989
if self._conn is not None:
9090
self._conn.close()
9191
self._conn = None
92+
global g_session, g_session_path
93+
g_session = None
94+
g_session_path = None
9295

9396
def cleanup(self):
9497
try:
9598
if self._conn is not None:
9699
self._conn.close()
97100
self._conn = None
98101
shutil.rmtree(self._path)
102+
global g_session, g_session_path
103+
g_session = None
104+
g_session_path = None
99105
except: # noqa
100106
pass
101107

0 commit comments

Comments
 (0)