-
-
Notifications
You must be signed in to change notification settings - Fork 531
Pool doesn't keep connections open #563
Copy link
Copy link
Closed
Description
When using psycopg2 pool, specifically with the "close" parameter of putconn set to false, I was expecting behavior like the following:
- create a "pool" of connections, with an initial number of connections equal to the "minconn" argument
- When getconn is called, see if there is an available connection. If so, return it. If not, open a new connection and return that (up to "maxconn" total connections)
- When putconn is called, return the connection to the pool for re-use, but do not close it (unless the close argument is specified as True, documentation says default is False)
- On the next request to getconn, this connection is now available and so no new connection will be made
- perhaps (or perhaps not), after some time, unused connections would be closed and purged from the pool to prevent large numbers of only used once connections from laying around.
However, in my testing, this does not appear to be the case - rather, every time I call putconn, the connection is closed unless that would result in fewer than minconn connections. Is this expected behavior, or is my expected behavior correct? If this is expected behavior, then what is the point of using pool? Just providing a hard limit for the number of allowed simultaneous connections?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels