MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / get_session

Function get_session

database/db_session.py:88–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87@asynccontextmanager
88async def get_session() -> AsyncSession:
89 engine = get_async_engine(config.SAVE_DATA_OPTION)
90 if not engine:
91 yield None
92 return
93 AsyncSessionFactory = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
94 session = AsyncSessionFactory()
95 try:
96 yield session
97 await session.commit()
98 except Exception as e:
99 await session.rollback()
100 raise e
101 finally:
102 await session.close()

Callers 15

store_contentMethod · 0.90
store_commentMethod · 0.90
store_contentMethod · 0.90
store_commentMethod · 0.90
store_dynamicMethod · 0.90
store_contentMethod · 0.90
store_commentMethod · 0.90
store_contentMethod · 0.90
store_commentMethod · 0.90
store_contentMethod · 0.90
store_commentMethod · 0.90
store_contentMethod · 0.90

Calls 2

get_async_engineFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected