Flask App calling on itself not working

Hello!

I have a hosted flask web service on render, however I cannot call my own APIs to any sort of success because of workers failing to perform their tasks, I do not know what is going wrong but I would love to get some support to narrow down and fix the issue

Below is the traceback that it produces

[2023-12-12 10:20:48 +0000] [45] [CRITICAL] WORKER TIMEOUT (pid:979)
[2023-12-12 10:20:48 +0000] [979] [INFO] Worker exiting (pid: 979)
thread_id : thread_mTmz2641xUljzPRvZSVKqAWG
prompt    : Hello! wassup boi! u gotta check humankind.design yo!
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
[2023-12-12 10:20:48 +0000] [45] [ERROR] Worker (pid:979) exited with code 1
[2023-12-12 10:20:48 +0000] [45] [ERROR] Worker (pid:979) exited with code 1.
[2023-12-12 10:20:48 +0000] [982] [INFO] Booting worker with pid: 982
[2023-12-12 10:21:18 +0000] [45] [CRITICAL] WORKER TIMEOUT (pid:982)
[2023-12-12 10:21:18 +0000] [982] [INFO] Worker exiting (pid: 982)
thread_id : thread_mTmz2641xUljzPRvZSVKqAWG
prompt    : Hello! wassup boi! u gotta check humankind.design yo!
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
[2023-12-12 10:21:19 +0000] [45] [ERROR] Worker (pid:982) exited with code 1
[2023-12-12 10:21:19 +0000] [45] [ERROR] Worker (pid:982) exited with code 1.
[2023-12-12 10:21:19 +0000] [985] [INFO] Booting worker with pid: 985
[2023-12-12 10:21:51 +0000] [45] [CRITICAL] WORKER TIMEOUT (pid:985)
[2023-12-12 10:21:51 +0000] [985] [INFO] Worker exiting (pid: 985)
thread_id : thread_mTmz2641xUljzPRvZSVKqAWG
prompt    : Hello! wassup boi! u gotta check humankind.design yo!
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
[2023-12-12 10:21:52 +0000] [45] [ERROR] Worker (pid:985) exited with code 1
[2023-12-12 10:21:52 +0000] [45] [ERROR] Worker (pid:985) exited with code 1.
[2023-12-12 10:21:52 +0000] [988] [INFO] Booting worker with pid: 988
[2023-12-12 10:22:27 +0000] [45] [CRITICAL] WORKER TIMEOUT (pid:988)
[2023-12-12 10:22:27 +0000] [988] [INFO] Worker exiting (pid: 988)
thread_id : thread_mTmz2641xUljzPRvZSVKqAWG
prompt    : Hello! wassup boi! u gotta check humankind.design yo!
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
[2023-12-12 10:22:27 +0000] [45] [ERROR] Worker (pid:988) exited with code 1
[2023-12-12 10:22:27 +0000] [45] [ERROR] Worker (pid:988) exited with code 1.
[2023-12-12 10:22:27 +0000] [991] [INFO] Booting worker with pid: 991
[2023-12-12 10:23:07 +0000] [45] [CRITICAL] WORKER TIMEOUT (pid:991)
[2023-12-12 10:23:07 +0000] [991] [INFO] Worker exiting (pid: 991)
thread_id : thread_mTmz2641xUljzPRvZSVKqAWG
prompt    : Hello! wassup boi! u gotta check humankind.design yo!
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
Error :Error code: 400 - {'error': {'message': 'Thread thread_mTmz2641xUljzPRvZSVKqAWG already has an active run run_rR6ycQTIZiXDpEqvLzdzpClZ.', 'type': 'invalid_request_error', 'param': None, 'code': None}}
[2023-12-12 10:23:08 +0000] [45] [ERROR] Worker (pid:991) exited with code 1
[2023-12-12 10:23:08 +0000] [45] [ERROR] Worker (pid:991) exited with code 1.
[2023-12-12 10:23:08 +0000] [994] [INFO] Booting worker with pid: 994

edit: Changed logs to match the most current attempt

Hi there,

It looks like you are getting a Gunicorn worker timeout. This defaults to 30 seconds: https://docs.gunicorn.org/en/stable/settings.html#timeout.

I’m unsure if this relates to your issues with OpenAI threads, but it looks like you are trying to “run” a thread multiple times. If I had to guess, you are getting into a loop here until you hit the worker timeout.

Regards,

Keith
Render Support, UTC+10 :australia:

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