Skip to content

Commit

Permalink
Merge pull request #994 from roboflow/flush-usage-collector-on-shutdown
Browse files Browse the repository at this point in the history
Flush usage_collector on shutdown
  • Loading branch information
grzegorz-roboflow authored Feb 4, 2025
2 parents 36780c7 + bb2b01a commit 612df6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions inference/core/interfaces/http/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import base64
import os
import traceback
from contextlib import asynccontextmanager
from functools import partial, wraps
from time import sleep
from typing import Any, Dict, List, Optional, Union
Expand Down Expand Up @@ -494,8 +495,17 @@ def __init__(
Description:
Deploy Roboflow trained models to nearly any compute environment!
"""

description = "Roboflow inference server"

@asynccontextmanager
async def lifespan(app: FastAPI):
yield
logger.info("Shutting down %s", description)
await usage_collector.async_push_usage_payloads()

app = FastAPI(
lifespan=lifespan,
title="Roboflow Inference Server",
description=description,
version=__version__,
Expand Down
2 changes: 1 addition & 1 deletion inference/core/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.36.1"
__version__ = "0.36.2"


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.http.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uvicorn[standard]<=0.22.0
uvicorn[standard]<=0.34.0
python-multipart==0.0.19
fastapi-cprofile<=0.0.2
orjson>=3.9.10,<=3.10.11
Expand Down

0 comments on commit 612df6b

Please sign in to comment.