Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-23 Thread tonthon
Thanks for those debug tips. It doesn't seem to be a celery related problem. Sessions are initiated after the fork and SQLAlchemy is not used as the messaging backend (We use Redis). Playing with the pool_recycle option in the Pyramid configuration I clearly limited the number of exceptions.

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-17 Thread Jonathan Vanasco
On Wednesday, April 17, 2019 at 4:36:30 AM UTC-4, tonthon wrote: > > May the scoped_session factory, used in both services (web and celery), > may cause such a problem ? > Apologies for my earlier reply, that would only affect exceptions in Celery. I do suggest checking your Celery code to ma

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-17 Thread tonthon
Yes, celery is running in a separate service. The objects are never passed from the web app to the celery service, only ids are passed, Objects are then retrieved on the celery side. May the scoped_session factory, used in both services (web and celery), may cause such a problem ? Le 16/04/

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-16 Thread Jonathan Vanasco
On Tuesday, April 16, 2019 at 9:41:39 AM UTC-4, Mike Bayer wrote: > > On Tue, Apr 16, 2019 at 4:49 AM tonthon wrote: > > > > Celery tasks are using the same scoped_session factory, could it cause > the errors we're facing here ? > Is Celery running as threads or multiprocessing? IIRC, it u

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-16 Thread Mike Bayer
Note also the objects can be copied using copy.deepcopy(), or pickle loads()/dumps(), before sending them to the other Session. This might not have worked in older Python / SQLAlchemy versions but deepcopy() seems to rely upon the pickle internals e.g. __setstate__, which in SQLAlchemy will cor

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-16 Thread Mike Bayer
On Tue, Apr 16, 2019 at 4:49 AM tonthon wrote: > > Celery tasks are using the same scoped_session factory, could it cause the > errors we're facing here ? what's important is if these tasks run in the same process or not ? ( i thought celery runs as a separate service?) If you are passing O

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-16 Thread tonthon
Celery tasks are using the same scoped_session factory, could it cause the errors we're facing here ? Le 15/04/2019 à 15:39, Mike Bayer a écrit : On Mon, Apr 15, 2019 at 5:41 AM tonthon wrote: I tried to set a lower value for the pool_recycle value and it seems to work. There is a celery se

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-15 Thread Mike Bayer
On Mon, Apr 15, 2019 at 5:41 AM tonthon wrote: > > I tried to set a lower value for the pool_recycle value and it seems to work. > > There is a celery service running in the background, maybe it could affect > the session management. this will reduce the problem but the architectural issue that

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-15 Thread tonthon
I tried to set a lower value for the pool_recycle value and it seems to work. There is a celery service running in the background, maybe it could affect the session management. Le 12/04/2019 à 15:58, Mike Bayer a écrit : it's likely that a database connection is being returned to the pool in

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-12 Thread Mike Bayer
it's likely that a database connection is being returned to the pool in an invalid state. Switching to NullPool temporarily might reveal that this solves all the issues ; at the very least, I would try setting pool_recycle to a low number, like 5 minutes, however this won't prevent the problem, ju

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-12 Thread tonthon
Le 10/04/2019 à 17:12, Mike Bayer a écrit : On Wed, Apr 10, 2019 at 9:23 AM tonthon wrote: Hi, We're using sqlalchemy in a Pyramid Web Application. We use the ZopeTransactionExtension and our session factory is initialized this way : DBSession = scoped_session(sessionmaker(extension=ZopeT

Re: [sqlalchemy] Commands out of sync; you can't run this command now

2019-04-10 Thread Mike Bayer
On Wed, Apr 10, 2019 at 9:23 AM tonthon wrote: > > Hi, > > We're using sqlalchemy in a Pyramid Web Application. > > We use the ZopeTransactionExtension and our session factory is initialized > this way : > > >>> DBSession = > >>> scoped_session(sessionmaker(extension=ZopeTransactionExtension()))

[sqlalchemy] Commands out of sync; you can't run this command now

2019-04-10 Thread tonthon
Hi, We're using sqlalchemy in a Pyramid Web Application. We use the ZopeTransactionExtension and our session factory is initialized this way : >>> DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) We use the pyramid_tm that wraps each web requests in a transact