On Mon, Nov 13, 2017 at 4:35 PM, Ahmad Javed <[email protected]> wrote:
> Thank you Simon. Appreciate your response. Just using session.remove() at
> the end of each request is not closing the connection and leave open
> connections in MySQL database. One more thing I want to tell that we have
> deployed Django applications with uwsgi and nginx.

Well, this is deliberate - closing the session returns the connection
to a pool, so that it can be used by a subsequent request. If it
didn't do this, it would have to create a new database connection for
every web request, which would be inefficient for a busy application.
You can read about SQLAlchemy's options for configuring the behaviour
of the connection pool at:

http://docs.sqlalchemy.org/en/latest/core/pooling.html

You should ensure that your pool_size and max_overflow options are set
appropriately. The pool should ensure that there are never more than
(pool_size + max_overflow) connections open to the database at once
per process.

If you are seeing more open connections than this, then something is
going wrong, and you'd need to start digging to find out why
connections aren't being returned to the pool.

Simon

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to