sunholo 0.144.0__py3-none-any.whl → 0.144.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,7 @@ import inspect
22
22
  import asyncio
23
23
  from typing import Dict, List, Optional, Callable, Any, TYPE_CHECKING
24
24
  from functools import partial
25
+ from contextlib import asynccontextmanager
25
26
 
26
27
  if TYPE_CHECKING:
27
28
  from fastapi import FastAPI, Request, Response, HTTPException
@@ -253,12 +254,36 @@ class VACRoutesFastAPI:
253
254
  methods=route.get("methods", ["GET"])
254
255
  )
255
256
 
256
- # Register startup event for MCP initialization
257
- @self.app.on_event("startup")
258
- async def startup_event():
259
- if self.mcp_servers and self.mcp_client_manager and not self._mcp_initialized:
257
+ # Set up lifespan for MCP initialization
258
+ self._setup_lifespan()
259
+
260
+ def _setup_lifespan(self):
261
+ """Set up lifespan context manager for app initialization."""
262
+ # Only set lifespan if we have MCP servers to initialize
263
+ if not (self.mcp_servers and self.mcp_client_manager):
264
+ return
265
+
266
+ # Store the existing lifespan if any
267
+ existing_lifespan = getattr(self.app, 'router', self.app).lifespan_context
268
+
269
+ @asynccontextmanager
270
+ async def lifespan(app: FastAPI):
271
+ # Startup
272
+ if not self._mcp_initialized:
260
273
  await self._initialize_mcp_servers()
261
274
  self._mcp_initialized = True
275
+
276
+ # Call existing lifespan startup if any
277
+ if existing_lifespan:
278
+ async with existing_lifespan(app) as lifespan_state:
279
+ yield lifespan_state
280
+ else:
281
+ yield
282
+
283
+ # Shutdown (no cleanup needed for now)
284
+
285
+ # Set the new lifespan
286
+ self.app.router.lifespan_context = lifespan
262
287
 
263
288
  async def home(self):
264
289
  """Home endpoint."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.144.0
3
+ Version: 0.144.1
4
4
  Summary: AI DevOps - a package to help deploy GenAI to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -16,7 +16,7 @@ sunholo/agents/swagger.py,sha256=2tzGmpveUMmTREykZvVnDj3j295wyOMu7mUFDnXdY3c,106
16
16
  sunholo/agents/fastapi/__init__.py,sha256=f7x7kiEjaNyBiOwJHLJ4vdOiePqkXdI52sIAAHtS-ms,141
17
17
  sunholo/agents/fastapi/base.py,sha256=W-cyF8ZDUH40rc-c-Apw3-_8IIi2e4Y9qRtnoVnsc1Q,2521
18
18
  sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhBlV3to-s,3864
19
- sunholo/agents/fastapi/vac_routes.py,sha256=cU5_t7VCbu1_6zrUBbyekEC3N7LUQCpJzr8nQGKInPM,42143
19
+ sunholo/agents/fastapi/vac_routes.py,sha256=sK2FuJsOBgc8sIKtTOYuyhNql5JX63U_hMpQQ-nLcug,42985
20
20
  sunholo/agents/flask/__init__.py,sha256=dEoByI3gDNUOjpX1uVKP7uPjhfFHJubbiaAv3xLopnk,63
21
21
  sunholo/agents/flask/base.py,sha256=vnpxFEOnCmt9humqj-jYPLfJcdwzsop9NorgkJ-tSaU,1756
22
22
  sunholo/agents/flask/vac_routes.py,sha256=kaPUDyIH5KhCgeCEtag97qErGVZfqpY1ZEiX3y1_r-s,57505
@@ -179,9 +179,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
179
179
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
180
180
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
181
181
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
182
- sunholo-0.144.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
183
- sunholo-0.144.0.dist-info/METADATA,sha256=SMIB3kckTnKrsx4HfMgnhaMiEl3MOKZzguwC4tFdLec,18700
184
- sunholo-0.144.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
185
- sunholo-0.144.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
186
- sunholo-0.144.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
187
- sunholo-0.144.0.dist-info/RECORD,,
182
+ sunholo-0.144.1.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
183
+ sunholo-0.144.1.dist-info/METADATA,sha256=ia-s14a5R5yxApJZGGqqeT2ebAlxEyc5AJhniD9xtxg,18700
184
+ sunholo-0.144.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
185
+ sunholo-0.144.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
186
+ sunholo-0.144.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
187
+ sunholo-0.144.1.dist-info/RECORD,,