Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting TimeoutError with SqlAlchemy
    primarykey
    data
    text
    <p><em>Update</em>: just figured out that echo_pool=True only shows major events, using echo_pool="debug" instead.</p> <p>I have to explicitly close the engine connection, otherwise I get a <code>TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30</code> error when using nosetest and sqlalchemy.</p> <p>I'm following the SqlAlchemy documentation about how to <a href="http://docs.sqlalchemy.org/en/rel_0_7/orm/session.html#joining-a-session-into-an-external-transaction" rel="nofollow">join a Session into an external transaction</a>. The only difference is that I'm using a scopedsession. Here is the offending code:</p> <pre><code>import unittest from sqlalchemy import create_engine from myapp.mymodel import Session engine = create_engine( '&lt;REDACTED&gt;', echo = False, # To make it faster to fail, but also fails with the default options # pool_size=2, # max_overflow=0, # echo_pool="debug", # pool_timeout=10, ) class MyTest(unittest.TestCase): def setUp(self): self.connection = engine.connect() # begin a non-ORM transaction self.trans = self.connection.begin() # bind an individual Session to the connection Session.configure(bind=self.connection) self.addCleanup(self._teardown) def _teardown(self): """Rollback the db. Added to the list of cleanup by setUp, so that subclass do not have to call super() on tearDown. """ # Rollback database self.trans.rollback() # Session must be closed BEFORE being removed Session.close() Session.remove() # If I don't do that, I get TimeOut # self.connection.close() </code></pre> <p>Here's the <code>echo_pool</code> debug output:</p> <pre><code>2012-09-11 12:34:28,506 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bae1e20&gt; 2012-09-11 12:34:28,514 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bae1e20&gt; checked out from pool 2012-09-11 12:34:29,664 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bc61c20&gt; 2012-09-11 12:34:29,665 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bc61c20&gt; checked out from pool 2012-09-11 12:34:30,368 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bc9ea20&gt; 2012-09-11 12:34:30,369 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bc9ea20&gt; checked out from pool 2012-09-11 12:34:31,042 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcd6820&gt; 2012-09-11 12:34:31,043 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcd6820&gt; checked out from pool 2012-09-11 12:34:31,775 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcbd820&gt; 2012-09-11 12:34:31,775 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcbd820&gt; checked out from pool 2012-09-11 12:34:32,439 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcc2220&gt; 2012-09-11 12:34:32,439 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcc2220&gt; checked out from pool 2012-09-11 12:34:33,129 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd0e220&gt; 2012-09-11 12:34:33,129 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd0e220&gt; checked out from pool 2012-09-11 12:34:33,802 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd1e420&gt; 2012-09-11 12:34:33,802 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd1e420&gt; checked out from pool 2012-09-11 12:34:34,590 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcf6a20&gt; 2012-09-11 12:34:34,590 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bcf6a20&gt; checked out from pool 2012-09-11 12:34:35,452 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd53420&gt; 2012-09-11 12:34:35,452 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd53420&gt; checked out from pool 2012-09-11 12:34:36,276 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd32420&gt; 2012-09-11 12:34:36,276 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd32420&gt; checked out from pool 2012-09-11 12:34:36,970 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd80420&gt; 2012-09-11 12:34:36,971 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd80420&gt; checked out from pool 2012-09-11 12:34:37,639 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bda9020&gt; 2012-09-11 12:34:37,640 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bda9020&gt; checked out from pool 2012-09-11 12:34:37,664 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bdc3c20&gt; 2012-09-11 12:34:37,664 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bdc3c20&gt; checked out from pool 2012-09-11 12:34:37,675 DEBUG sqlalchemy.pool.QueuePool Created new connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd95e20&gt; 2012-09-11 12:34:37,675 DEBUG sqlalchemy.pool.QueuePool Connection &lt;_mysql.connection open to '127.0.0.1' at 7f938bd95e20&gt; checked out from pool </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload