You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is reproduceable only when python is run as a child subprocess of another process (e.g. if you spawn it from another program or run in a jupyter playbook) and tested on windows, probably linux handles simultaneous stdin reads better.
Reading from stdin is a common pattern on windows (sadly) to handle graceful shutdowns because OS doesn't have signals like posix os.
To reproduce, run this code in a jupyter playbook:
importos, sysimportthreadingimportsignalfrompydubimportAudioSegmentdefwindows_graceful_shutdown_listener():
""" Windows doesn't have signals, so we need to listen to stdin for quit command """forlineinsys.stdin:
ifline=="quit\n":
signal.raise_signal(signal.SIGINT)
threading.Thread(target=windows_graceful_shutdown_listener, daemon=True).start()
video_uri="C:/path/to/file/video.mp4"audio_file=AudioSegment.from_file(video_uri, start_second=0, duration=10)
audio_file.set_frame_rate(16000)
audio_file.export("test.wav", format="wav")
Expected behavior
pydub shouldn't hang and complete the work, or at least throw a timeout exception if it can not read from stdin.
Actual behavior
pydub hangs in a deadlock state indefinitely.
Your System configuration
Python version: 3.12.4
Pydub version: 0.25.1
ffmpeg or avlib?: ffmpeg
ffmpeg/avlib version: 6.0
Is there an audio file you can include to help us reproduce?
Works on any audio or video file
The text was updated successfully, but these errors were encountered:
ggolda
added a commit
to Salmondx/pydub
that referenced
this issue
Dec 18, 2024
Steps to reproduce
Looks like pydub attempts to read the stdin in the scenario below in
audio_segment.py
(https://github.com/jiaaro/pydub/blob/master/pydub/audio_segment.py#L766). If another python thread is currently trying to read from stdin, pydub gets stuck forever in a deadlock state.This is reproduceable only when python is run as a child subprocess of another process (e.g. if you spawn it from another program or run in a jupyter playbook) and tested on windows, probably linux handles simultaneous stdin reads better.
Reading from stdin is a common pattern on windows (sadly) to handle graceful shutdowns because OS doesn't have signals like posix os.
To reproduce, run this code in a jupyter playbook:
Expected behavior
pydub shouldn't hang and complete the work, or at least throw a timeout exception if it can not read from stdin.
Actual behavior
pydub hangs in a deadlock state indefinitely.
Your System configuration
Is there an audio file you can include to help us reproduce?
Works on any audio or video file
The text was updated successfully, but these errors were encountered: