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 proc.stdin:
|
||||
# Run blocking pipe-write in a real thread via tpool
|
||||
eventlet.tpool.execute(proc.stdin.write, chunk)
|
||||
eventlet.tpool.execute(proc.stdin.flush)
|
||||
proc.stdin.write(chunk)
|
||||
proc.stdin.flush()
|
||||
except queue.Empty:
|
||||
continue
|
||||
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})")
|
||||
while proc.poll() is None:
|
||||
try:
|
||||
# Run blocking pipe-read in a real thread via tpool (1 KB chunks
|
||||
# for smooth delivery; prevents buffering delays at lower bitrates)
|
||||
data = eventlet.tpool.execute(proc.stdout.read, 1024)
|
||||
data = proc.stdout.read(1024)
|
||||
if not data: break
|
||||
_transcoder_bytes_out += len(data)
|
||||
|
||||
|
|
@ -340,7 +337,7 @@ def _start_srt_transcoder():
|
|||
print(f'[THREAD] SRT reader started (PID: {proc.pid})')
|
||||
while proc.poll() is None:
|
||||
try:
|
||||
data = eventlet.tpool.execute(proc.stdout.read, 4096)
|
||||
data = proc.stdout.read(4096)
|
||||
if not data:
|
||||
break
|
||||
_transcoder_bytes_out += len(data)
|
||||
|
|
@ -1131,7 +1128,7 @@ def mediamtx_webhook():
|
|||
broadcast_state['is_mp3_input'] = False
|
||||
_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:
|
||||
_preroll_clear()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue