Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start a gevent based worker if httpx is intalled #9032

Open
pg1671 opened this issue May 19, 2024 · 5 comments
Open

Can't start a gevent based worker if httpx is intalled #9032

pg1671 opened this issue May 19, 2024 · 5 comments

Comments

@pg1671
Copy link

pg1671 commented May 19, 2024

If the python module httpx is installed then I cannot start a gevent based worker.

Checked against latest celery 5.4.0 running on Python 3.11 on ubuntu 20.04.

If I change the pool to prefork it starts.

If I uninstall httpx it works again with gevent.

I see nothing logged to my celery log file even with DEBUG level logging.

The command line output seems to indicate the worker is started ok.

celery multi v5.4.0 (opalescent)

Starting nodes...
> agent-async@ip-172-31-44-30: OK

but there are no processes for the worker if I run:
ps -aux | grep celery

No PID file is created.

There seems to be some conflict with celery\gevent and httpx.

@pg1671
Copy link
Author

pg1671 commented Jun 9, 2024

This issue was due to the latest openai python package using httpx .. I pinned it to the old version that didn't require it as my worker will run in a gevent pool.

Then I installed some more AI libraries and they must have httpx as a dependancy and my gevent worker died again.

My application does not use httpx so I assume some dependency is using it if available but it is failing under gevent causing the application to fail. If I just remove the httpx package everything works.

However, there are no logs of failure anywhere. Nothing in my celery log file (with debug) nothing in my systemd service logs. My systemd server just continually restarts.

How do I debug something like this? I would like to move my OpenAI calls to use an async worker pool as well but not sure where the problem is.

@pg1671
Copy link
Author

pg1671 commented Jun 9, 2024

Issue tracked to Trio (a dependency of httpx) not working under gevent (or eventlet).

python-trio/trio#3013

@Roman-Ka
Copy link

@pg1671 My workers are starting but httpx streams are sometimes broken, which verstion of OpenAI did you go with in the end?

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

@Roman-Ka .. I don't use httpx yet (plan to). I just pinned to openai < 1.0.0 on the installation that was gevent based as it didn't use openai .. we are using prefork queues for that though will move to gevent workers when these issues are fixed.

My gevent workers will just fail without any errors if httpx is installed which was ultimately the importing of trio (see above).

The trio team are pretty proactive so hopefully they can resolve it but looks like they might need explicit support for gevent\eventlet etc in their package to resolve.

I now just uninstall trio and am free to use httpx but not sure how well it will work under gevent.

@pg1671
Copy link
Author

pg1671 commented Jun 10, 2024

@Roman-Ka .. are you workers gevent or eventlet based? My prefork queues are ok with openai and I have the latest openai installed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants