Worker Timeout Error

I am fairly new to backend, and I am using Python with Flask for my backend which deals with pdf conversions by getting the url from firebase storage and converting it in the backend and then uploading it to the firebase.
Some of my function works, but some of my function doesn’t for instance when I try to call the function compress-pdf it gives me error, but when calling pdf-to-ppt it works fine. I get it that it has something to do with the time it is taking for the two functions to return. But how exactly do I fix it?

This is the error I am getting
May 25 09:52:58 PM 127.0.0.1 - - [25/May/2023:16:22:58 +0000] "OPTIONS /api/protect-pdf HTTP/1.1" 200 0 "http://localhost:3000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" May 25 09:53:30 PM [2023-05-25 16:23:30 +0000] [54] [CRITICAL] WORKER TIMEOUT (pid:78) May 25 09:53:30 PM [2023-05-25 16:23:30 +0000] [78] [INFO] Worker exiting (pid: 78) May 25 09:53:31 PM [2023-05-25 16:23:31 +0000] [54] [WARNING] Worker with pid 78 was terminated due to signal 9 May 25 09:53:31 PM [2023-05-25 16:23:31 +0000] [79] [INFO] Booting worker with pid: 79

So how can I fix this error?

Hi Rayyan,

Gunicorn has a default timeout of 30 seconds. If compress-pdf takes longer than the timeout, this is the error you will see. Ideally, it would be best if you were moving the work of converting the PDF’s to a background worker so you are not tying up your Gunicorn workers for extended periods.

Regards,
Keith

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.