- changed status to resolved
Problem with engines created with pool keyword argument specified
Issue #145
resolved
Here's a piece of sqlalchemy/engine.py file (near beginning of SQLEngine constructor, line 239):
if pool is None:
params['echo']('echo') = echo_pool
params['use_threadlocal']('use_threadlocal') = True
self._pool = sqlalchemy.pool.manage(self.dbapi(), **params).get_pool(*cargs, **cparams)
else:
self._pool = pool
As you can see if pool is specified that it is used just as provided. But if it is not specified than additional call to method get_pool() is made.
But documentation http://www.sqlalchemy.org/docs/pooling.myt#pooling_establishing shows an example:
import psycopg2 as psycopg
psycopg = pool.manage(psycopg)
And if that pool is uses as as parameter to create_engine() than it won't work.
I suppose engine.py should be changed to something like:
if pool is None:
params['echo']('echo') = echo_pool
params['use_threadlocal']('use_threadlocal') = True
self._pool = sqlalchemy.pool.manage(self.dbapi(), **params).get_pool(*cargs, **cparams)
else:
self._pool = pool.get_pool(*cargs, **cparams)
Here is a diff file:
Index: engine.py
===================================================================
--- engine.py (revision 1236)
+++ engine.py (working copy)
@@ -241,7 +241,7 @@
params['use_threadlocal']('use_threadlocal') = True
self._pool = sqlalchemy.pool.manage(self.dbapi(), **params).get_pool(*cargs, **cparams)
else:
- self._pool = pool
+ self._pool = pool.get_pool(*cargs, **cparams)
self.default_ordering=default_ordering
self.echo = echo
self.echo_uow = echo_uow
Comments (1)
-
repo owner - Log in to comment
well, theres two conflicting patterns documented:
http://www.sqlalchemy.org/docs/dbengine.myt#database_options
and then the docstrings which say its a DBProxy. So I put some isinstance() stuff in there so it can be either one, as of changeset:1267.