pranavajay
commited on
Update api.py
Browse files
api.py
CHANGED
@@ -5,7 +5,9 @@ import random
|
|
5 |
import string
|
6 |
import numpy as np
|
7 |
import logging
|
|
|
8 |
import datetime
|
|
|
9 |
from fastapi import FastAPI, HTTPException, Request, Response
|
10 |
from fastapi.middleware.cors import CORSMiddleware
|
11 |
from pydantic import BaseModel, constr, conint
|
@@ -711,6 +713,7 @@ async def generate_video(req: GenerateImageRequest):
|
|
711 |
raise HTTPException(status_code=500, detail=f"Failed to generate video after multiple attempts: {str(e)}")
|
712 |
continue # Retry on transient errors
|
713 |
|
|
|
714 |
@app.on_event("shutdown")
|
715 |
def shutdown_event():
|
716 |
""" Perform any cleanup activities on shutdown. """
|
|
|
5 |
import string
|
6 |
import numpy as np
|
7 |
import logging
|
8 |
+
import aysncio
|
9 |
import datetime
|
10 |
+
from contextlib import asynccontextmanager
|
11 |
from fastapi import FastAPI, HTTPException, Request, Response
|
12 |
from fastapi.middleware.cors import CORSMiddleware
|
13 |
from pydantic import BaseModel, constr, conint
|
|
|
713 |
raise HTTPException(status_code=500, detail=f"Failed to generate video after multiple attempts: {str(e)}")
|
714 |
continue # Retry on transient errors
|
715 |
|
716 |
+
@asynccontextmanager
|
717 |
@app.on_event("shutdown")
|
718 |
def shutdown_event():
|
719 |
""" Perform any cleanup activities on shutdown. """
|