fix: remove publisher_ip NameError; replace eventlet.tpool with direct IO
This commit is contained in:
parent
9150d3cc83
commit
0e0be1069b
13
server.py
13
server.py
|
|
@ -202,9 +202,8 @@ def _start_transcoder_if_needed(is_mp3_input=False):
|
||||||
if chunk is None: break
|
if chunk is None: break
|
||||||
|
|
||||||
if proc.stdin:
|
if proc.stdin:
|
||||||
# Run blocking pipe-write in a real thread via tpool
|
proc.stdin.write(chunk)
|
||||||
eventlet.tpool.execute(proc.stdin.write, chunk)
|
proc.stdin.flush()
|
||||||
eventlet.tpool.execute(proc.stdin.flush)
|
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
continue
|
continue
|
||||||
except (BrokenPipeError, ConnectionResetError):
|
except (BrokenPipeError, ConnectionResetError):
|
||||||
|
|
@ -226,9 +225,7 @@ def _start_transcoder_if_needed(is_mp3_input=False):
|
||||||
print(f"[THREAD] Transcoder reader started (PID: {proc.pid})")
|
print(f"[THREAD] Transcoder reader started (PID: {proc.pid})")
|
||||||
while proc.poll() is None:
|
while proc.poll() is None:
|
||||||
try:
|
try:
|
||||||
# Run blocking pipe-read in a real thread via tpool (1 KB chunks
|
data = proc.stdout.read(1024)
|
||||||
# for smooth delivery; prevents buffering delays at lower bitrates)
|
|
||||||
data = eventlet.tpool.execute(proc.stdout.read, 1024)
|
|
||||||
if not data: break
|
if not data: break
|
||||||
_transcoder_bytes_out += len(data)
|
_transcoder_bytes_out += len(data)
|
||||||
|
|
||||||
|
|
@ -340,7 +337,7 @@ def _start_srt_transcoder():
|
||||||
print(f'[THREAD] SRT reader started (PID: {proc.pid})')
|
print(f'[THREAD] SRT reader started (PID: {proc.pid})')
|
||||||
while proc.poll() is None:
|
while proc.poll() is None:
|
||||||
try:
|
try:
|
||||||
data = eventlet.tpool.execute(proc.stdout.read, 4096)
|
data = proc.stdout.read(4096)
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
_transcoder_bytes_out += len(data)
|
_transcoder_bytes_out += len(data)
|
||||||
|
|
@ -1131,7 +1128,7 @@ def mediamtx_webhook():
|
||||||
broadcast_state['is_mp3_input'] = False
|
broadcast_state['is_mp3_input'] = False
|
||||||
_mp3_broadcast_announced = True # SRT audio starts flowing immediately
|
_mp3_broadcast_announced = True # SRT audio starts flowing immediately
|
||||||
|
|
||||||
print(f"SRT: Stream PUBLISHED — path='{path}' source='{source_id}' ip='{publisher_ip or "unknown"}'")
|
print(f"SRT: Stream PUBLISHED — path='{path}' source='{source_id}'")
|
||||||
with _mp3_lock:
|
with _mp3_lock:
|
||||||
_preroll_clear()
|
_preroll_clear()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue