File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1+ import atexit
12import os
23from functools import lru_cache
34from typing import List , Optional
1314_agent_executor = None
1415
1516
16- @lru_cache ( maxsize = 1 )
17+ @lru_cache
1718def get_checkpointer ():
1819 DATABASE_URL = os .environ .get ("DATABASE_URL" )
1920 if not DATABASE_URL :
2021 raise RuntimeError ("DATABASE_URL is not set. Point it to your Neon connection string." )
2122
22- checkpointer = PostgresSaver .from_conn_string (DATABASE_URL )
23- checkpointer .setup () # create tables on first run; no-op afterward
24- return checkpointer
23+ cm = PostgresSaver .from_conn_string (DATABASE_URL )
24+ saver = cm .__enter__ () # enter the context manager once
25+ atexit .register (lambda : cm .__exit__ (None , None , None )) # clean shutdown
26+ saver .setup () # create tables on first run; no-op afterward
27+ return saver
2528
2629
2730def get_agent ():
You can’t perform that action at this time.
0 commit comments