disable pool_threadlocal by default

Issue #1049 resolved
Mike Bayer repo owner created an issue

this is the patch. PG has issues with deadlocks in some tests, like zoomark, so apply the patch and get those tests to work:

Index: test/orm/session.py
===================================================================
--- test/orm/session.py (revision 4772)
+++ test/orm/session.py (working copy)
@@ -357,7 +357,20 @@
         session.commit()
         assert session.connection().execute("select count(1) from users").scalar() == 2

-
+    @testing.fails_on('sqlite')
+    @testing.resolve_artifact_names
+    def test_transactions_isolated(self):
+        mapper(User, users)
+        users.delete().execute()
+        
+        s1 = create_session(bind=testing.db, autocommit=False)
+        s2 = create_session(bind=testing.db, autocommit=False)
+        u1 = User(name='u1')
+        s1.add(u1)
+        s1.flush()
+        
+        assert s2.query(User).all() == []
+        
     @testing.requires.two_phase_transactions
     @testing.resolve_artifact_names
     def test_twophase(self):
Index: lib/sqlalchemy/pool.py
===================================================================
--- lib/sqlalchemy/pool.py  (revision 4767)
+++ lib/sqlalchemy/pool.py  (working copy)
@@ -116,8 +116,9 @@
       resources.  Disable at your own peril.

     """
-    def __init__(self, creator, recycle=-1, echo=None, use_threadlocal=True,
+    def __init__(self, creator, recycle=-1, echo=None, use_threadlocal=False,
                  reset_on_return=True, listeners=None):
+
         self.logger = log.instance_logger(self, echoflag=echo)
         # the WeakValueDictionary works more nicely than a regular dict of
         # weakrefs.  the latter can pile up dead reference objects which don't
Index: lib/sqlalchemy/engine/strategies.py
===================================================================
--- lib/sqlalchemy/engine/strategies.py (revision 4767)
+++ lib/sqlalchemy/engine/strategies.py (working copy)
@@ -134,7 +134,7 @@
         DefaultEngineStrategy.__init__(self, 'plain')

     def pool_threadlocal(self):
-        return True
+        return False

     def get_engine_cls(self):
         return base.Engine

Comments (2)

  1. Log in to comment