Discussion:
per-worker initialization to prevent shared SQL connection pools?
egradman
2010-11-11 19:09:38 UTC
Permalink
My tasks import some SQLAlchemy code that creates an engine. I
believe that the engine is created prior to the worker processes
forking, and that the connection pool shared among processes is
causing some disconnection issues. Is there some way of doing per-
worker initialization, so each worker can instantiate its own engine?

I'm not using SQLAlchemy for any celery functionality (queueing,
tombstones); I'm only using it inside the tasks. I'm using the
postgres dbapi.
JoNO .
2010-11-12 02:30:20 UTC
Permalink
Did you try the `worker_process_init` signal ?

http://ask.github.com/celery/reference/celery.signals.html#worker-signals
Post by egradman
My tasks import some SQLAlchemy code that creates an engine. I
believe that the engine is created prior to the worker processes
forking, and that the connection pool shared among processes is
causing some disconnection issues. Is there some way of doing per-
worker initialization, so each worker can instantiate its own engine?
I'm not using SQLAlchemy for any celery functionality (queueing,
tombstones); I'm only using it inside the tasks. I'm using the
postgres dbapi.
--
You received this message because you are subscribed to the Google Groups
"celery-users" group.
To unsubscribe from this group, send email to
.
For more options, visit this group at
http://groups.google.com/group/celery-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "celery-users" group.
To post to this group, send email to celery-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to celery-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/celery-users?hl=en.
Gijs Koot
2015-02-19 12:03:59 UTC
Permalink
The worker_process_init signal is in principle a good place to initialize a
connection, however, during execution of a task you don't have access to
the worker (except for some far-fetched multiprocessing / multithreading
magic), so how would you be getting hold of the connection? I've seen this
one
http://stackoverflow.com/questions/14526249/celery-worker-database-connection-pooling
but it seems suspect. Thanks for helping.
--
You received this message because you are subscribed to the Google Groups "celery-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to celery-users+***@googlegroups.com.
To post to this group, send email to celery-***@googlegroups.com.
Visit this group at http://groups.google.com/group/celery-users.
For more options, visit https://groups.google.com/d/optout.
Loading...