First Check
Commit to Help
Example Code
from fastapi.applications import FastAPI
import uvicorn
from fastapi.requests import Request
from fastapi.responses import StreamingResponse
from visitor_camera_fastapi import VideoCameraV
app = FastAPI()
async def genv(camera, request):
while True:
print(f'is disconnect {request._is_disconnected}')
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.get("/getCameraStream")
async def detectEmployees(request:Request):
# body = await request.body()
query = request.query_params
return StreamingResponse(genv(VideoCameraV(request)), media_type='multipart/x-mixed-replace; boundary=frame')
Description
hi, In my project we capture the stream in the backend and passing to the front-end through API. If the front-end stop getting the stream .then also in the backend stream is getting pass. how Can I stop this stream
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.63.0
Python Version
3.7
Additional Context
I am getting the socket.send() error .there is way I can check the client is disconnect . I have tried with request._is_disconnected also but it returing false if the client disconnected also
First Check
Commit to Help
Example Code
Description
hi, In my project we capture the stream in the backend and passing to the front-end through API. If the front-end stop getting the stream .then also in the backend stream is getting pass. how Can I stop this stream
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.63.0
Python Version
3.7
Additional Context
I am getting the socket.send() error .there is way I can check the client is disconnect . I have tried with request._is_disconnected also but it returing false if the client disconnected also