[session] make session lock reentrant
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 22 Mar 2013 20:04:43 +0100
changeset 8776 cdb261bd36ac
parent 8775 3d932eec0bda
child 8777 4e72b78ea5aa
[session] make session lock reentrant We are going to use it for other session related business. It is renamed from _closed_lock to _lock in the same move.
server/session.py
--- a/server/session.py	Fri Mar 22 19:51:50 2013 +0100
+++ b/server/session.py	Fri Mar 22 20:04:43 2013 +0100
@@ -388,7 +388,7 @@
         self.__threaddata = threading.local()
         self._threads_in_transaction = set()
         self._closed = False
-        self._closed_lock = threading.Lock()
+        self._lock = threading.RLock()
 
     def __unicode__(self):
         return '<session %s (%s 0x%x)>' % (
@@ -861,7 +861,7 @@
 
     def set_cnxset(self):
         """the session need a connections set to execute some queries"""
-        with self._closed_lock:
+        with self._lock:
             if self._closed:
                 self.free_cnxset(True)
                 raise Exception('try to set connections set on a closed session %s' % self.id)
@@ -1153,7 +1153,7 @@
 
     def close(self):
         """do not close connections set on session close, since they are shared now"""
-        with self._closed_lock:
+        with self._lock:
             self._closed = True
         # copy since _threads_in_transaction maybe modified while waiting
         for thread, cnxset in self._threads_in_transaction.copy():