One of my project is built around Django rest framework and Sqlalchemy as ORM.

This application is thread based so randomly we are seeing one of thread 
transaction showing connection closed error.

Randomly when my application is trying to insert the record in table we are 
seeing exception the resource is closed, Below is stack trace:

"./modules/managers/contracts/contracts_manager.py", line 745, in 
submit_fix_contract#012    deal_amn_contract_activity_id = 
self.save_contract_activity_data(deal_contract_id,fix_request,response.text, 
'Submitted', 'Contract Submitted')#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/dtplatform/common/transaction.py",
 line 123, in inner#012    self.session.commit()#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 813, in commit#012    self.transaction.commit()#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 392, in commit#012    self._prepare_impl()#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 372, in _prepare_impl#012    self.session.flush()#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 2027, in flush#012    self._flush(objects)#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 2145, in _flush#012    transaction.rollback(_capture_exception=True)#012  
File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py",
 line 63, in __exit__#012    compat.reraise(type_, value, traceback)#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 2145, in _flush#012    transaction.rollback(_capture_exception=True)#012  
File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 408, in rollback#012    self._assert_active(prepared_ok=True, 
rollback_ok=True)#012  File 
"/opt/www/dt_deal_products_api/env/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
 line 223, in _assert_active#012    raise 
sa_exc.ResourceClosedError(closed_msg)#012ResourceClosedError: This transaction 
is closed

So my application is closing the connection after every commit or rollback so 
as per my understanding after connection close that connection will be return 
to pool for further use then why sqlalchemy is saying connection close in next 
transaction.

Is this error due to alchemy connection pool returning expired connection when 
requesting due to application is ideal for certain amount of time or connection 
is expiring at transaction time.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/51595dbe-5574-41ff-8fb7-05b17c9abbee%40googlegroups.com.

Reply via email to