1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 06:56:57 -05:00

Check If Chunk Method can close better

This commit is contained in:
deathbybandaid 2020-09-30 15:42:16 -04:00
parent 36b4078c62
commit 8a84364e0d

View File

@ -263,12 +263,16 @@ class HDHR_HTTP_Server():
req = requests.get(channelUri, stream=True)
def generate():
yield ''
for chunk in req.iter_content(chunk_size=hdhr.config["direct_stream"]['chunksize']):
if not duration == 0 and not time.time() < duration:
req.close()
break
yield chunk
try:
yield ''
for chunk in req.iter_content(chunk_size=hdhr.config["direct_stream"]['chunksize']):
if not duration == 0 and not time.time() < duration:
req.close()
break
yield chunk
except GeneratorExit:
req.close()
print("Connection Closed.")
return Response(generate(), content_type=req.headers['content-type'], direct_passthrough=True)