mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
22 lines
516 B
Python
22 lines
516 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from openhands.sdk.utils.models import DiscriminatedUnionMixin
|
|
|
|
|
|
class AppLifespanService(DiscriminatedUnionMixin, ABC):
|
|
def lifespan(self, api: FastAPI):
|
|
"""Return lifespan wrapper."""
|
|
return self
|
|
|
|
@abstractmethod
|
|
async def __aenter__(self):
|
|
"""Open lifespan."""
|
|
|
|
@abstractmethod
|
|
async def __aexit__(self, exc_type, exc_value, traceback):
|
|
"""Close lifespan."""
|