MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / stream_generator

Function stream_generator

core/views.py:190–209  ·  view source on GitHub ↗
(stdout_file, pid, persistent_lock)

Source from the content-addressed store, hash-verified

188 return HttpResponseServerError(f"Error preparing stream: {e}")
189
190 def stream_generator(stdout_file, pid, persistent_lock):
191 try:
192 while True:
193 chunk = stdout_file.read(8192)
194 if not chunk:
195 break
196 yield chunk
197 finally:
198 try:
199 os.kill(pid, signal.SIGTERM)
200 logger.debug("Streaming process terminated for channel ID=%s", channel.id)
201 except OSError:
202 pass
203 try:
204 os.waitpid(pid, os.WNOHANG)
205 except ChildProcessError:
206 pass
207 stdout_file.close()
208 persistent_lock.release()
209 logger.debug("Persistent lock released for channel ID=%s", channel.id)
210
211 return StreamingHttpResponse(
212 stream_generator(proc_stdout, proc_pid, persistent_lock),

Callers 2

stream_viewFunction · 0.85

Calls 4

readMethod · 0.80
killMethod · 0.45
closeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected