pydub AudioSegment taking forever

42 Views Asked by At

I'm really struggling with a pydub problem and I can't find a way out.

I am running a very simple script in my machine:

from pydub import AudioSegment
mp3_audio = AudioSegment.from_mp3('1334999.mp3')
print('end function')

which ends very quickly.

The problem is that I'm trying to run this script in a DAG with Airflow

from airflow import DAG
from datetime import datetime
from airflow.operators.python import PythonOperator

def simple_function():
   from pydub import AudioSegment
   mp3_audio = AudioSegment.from_mp3('1334999.mp3')
   print('end function')

with DAG(
   dag_id="simple_dag",
   start_date=datetime(2023, 1, 31, 15),
   schedule_interval=None,
   catchup=False
   )  as dag:

   simple_function = PythonOperator(
       task_id="simple_function",
       python_callable=simple_function
   )

When I start the DAG there is no error but the task keeps running for ages, up to a hour and won't finish. I tried to uninstall and install pydub, ffmpeg, but nothing changed. I used the same python to run the script and the DAG. Python 3.10 and airflow v2.7.1. Can someone help me ?

0

There are 0 best solutions below