On 06/29/2016 05:23 PM, Jonathon Nelson wrote:
I noticed some strange behavior with QueuePool when the pool_size is exactly 1. (this is with 1.0.13). With an app that basically does this: e = sa.create_engine(..., pool_size=N) while True: with e.begin() as trans: # perform a simple query I see this behavior (observed with strace, but turning on connection logging will do it too): With pool_size == 1, db connections opened, used, and then closed.
I don't see that (using netstat w/ mysql, I see one TCP connection, stays open). How are you detecting that db connections are "open"? Note that the pool also has an "overflow" that will allow it to go over "pool_size" if more than one connection is requested simultaneously. Set that to zero to get the pool to stay on exactly one connection.
With pool_size == 2, *two* database connections remain open, neither are closed. Something seems weird with pool_size==1. :-( The logs: DEBUG:sqlalchemy.pool.QueuePool:Created new connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> checked out from pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> being returned to pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> rollback-on-return DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> being returned to pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> rollback-on-return DEBUG:sqlalchemy.pool.QueuePool:Closing connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> checked out from pool DEBUG:sqlalchemy.pool.QueuePool:Created new connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> checked out from pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> being returned to pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> rollback-on-return DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> being returned to pool DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> rollback-on-return DEBUG:sqlalchemy.pool.QueuePool:Closing connection <connection object at 0x2d7db10; dsn: 'dbname=zarp', closed: 0> DEBUG:sqlalchemy.pool.QueuePool:Connection <connection object at 0x2dbb390; dsn: 'dbname=zarp', closed: 0> checked out from pool -- Jon Nelson Dyn / Principal Software Engineer p. +1 (603) 263-8029 -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.