Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,23 @@
|
|
| 1 |
import time
|
|
|
|
| 2 |
import datetime
|
|
|
|
| 3 |
from contextlib import asynccontextmanager
|
| 4 |
|
|
|
|
| 5 |
from fastapi import FastAPI
|
| 6 |
from fastapi_utilities import repeat_at
|
| 7 |
|
| 8 |
my_data = list( str('-') * 10 )
|
|
|
|
| 9 |
|
| 10 |
@asynccontextmanager
|
| 11 |
async def lifespan(app: FastAPI):
|
| 12 |
# --- startup ---
|
| 13 |
work() # no await!
|
|
|
|
|
|
|
|
|
|
| 14 |
yield
|
| 15 |
# --- shutdown ---
|
| 16 |
|
|
|
|
| 1 |
import time
|
| 2 |
+
import os
|
| 3 |
import datetime
|
| 4 |
+
import requests
|
| 5 |
from contextlib import asynccontextmanager
|
| 6 |
|
| 7 |
+
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi_utilities import repeat_at
|
| 10 |
|
| 11 |
my_data = list( str('-') * 10 )
|
| 12 |
+
START_STAT_URL = os.getenv('START_STAT_URL', '')
|
| 13 |
|
| 14 |
@asynccontextmanager
|
| 15 |
async def lifespan(app: FastAPI):
|
| 16 |
# --- startup ---
|
| 17 |
work() # no await!
|
| 18 |
+
# send stat info
|
| 19 |
+
if START_STAT_URL:
|
| 20 |
+
requests.get(f'{START_STAT_URL}?add=HF_der-opt_worker_start_event')
|
| 21 |
yield
|
| 22 |
# --- shutdown ---
|
| 23 |
|