On Tue, May 12, 2015 at 9:28 AM, Mike Bayer <mike...@zzzcomputing.com>
wrote:

>
>
> On 5/12/15 9:34 AM, Jonathon Nelson wrote:
>
> I'm working on an application where I want to use one and only one
> connection, even in the face of errors.
> Originally I used AssertionPool, but it seemed to misbehave sometimes in
> the face of a disconnection.
> Switching to QueuePool, I somewhat surprisingly got the same result.
>
> This is how I perform my test. Using the code below, I start it with a URI
> and wait for it to tell me to stop postgresql, which I then do.
> I hit enter, and get an (expected) error as it fails to connect.
> When I hit enter a second time, I get an *unexpected* traceback, a
> different one for QueuePool as for AssertionPool, but unexpected
> nonetheless.
>
> it would be super helpful if you could share what this traceback is.
>

Sure. Below find *two* runs (split on '*****************'), the first being
the one with AssertionPool and the latter with QueuePool.


*****************
Now stop PG.
-=>
Got an (expected) error:  (psycopg2.OperationalError) could not connect to
server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?

-=!
No handlers could be found for logger "sqlalchemy.pool.AssertionPool"
Traceback (most recent call last):
  File "t3.py", line 48, in <module>
    main()
  File "t3.py", line 36, in main
    with engine.begin() as conn:
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
1903, in begin
    conn = self.contextual_connect(close_with_result=close_with_result)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
2034, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
2069, in _wrap_pool_connect
    return fn()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 376,
in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 708,
in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 480,
in checkout
    rec = pool._do_get()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1257,
in _do_get
    raise AssertionError("connection is already checked out" + suffix)
AssertionError: connection is already checked out at:
  File "t3.py", line 48, in <module>
    main()
  File "t3.py", line 26, in main
    with engine.begin() as conn:

*****************
Now stop PG.
-=>
Got an (expected) error:  (psycopg2.OperationalError) could not connect to
server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?

-=!
No handlers could be found for logger "sqlalchemy.pool.QueuePool"
Traceback (most recent call last):
  File "t3.py", line 48, in <module>
    main()
  File "t3.py", line 36, in main
    with engine.begin() as conn:
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
1903, in begin
    conn = self.contextual_connect(close_with_result=close_with_result)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
2034, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line
2069, in _wrap_pool_connect
    return fn()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 376,
in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 708,
in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 480,
in checkout
    rec = pool._do_get()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1042,
in _do_get
    (self.size(), self.overflow(), self._timeout))
sqlalchemy.exc.TimeoutError: QueuePool limit of size 1 overflow 0 reached,
connection timed out, timeout 0
*****************


I hope this is helpful.

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to