response.custom_commit patch, thanks Jonathan
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.7 (2012-04-07 16:53:28) dev
|
Version 1.99.7 (2012-04-07 16:56:18) dev
|
||||||
|
|||||||
+22
-17
@@ -431,23 +431,28 @@ class ConnectionPool(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def close_all_instances(action):
|
def close_all_instances(action):
|
||||||
""" to close cleanly databases in a multithreaded environment """
|
""" to close cleanly databases in a multithreaded environment """
|
||||||
if not hasattr(thread, 'instances'):
|
if hasattr(thread, 'instances'):
|
||||||
return
|
while thread.instances:
|
||||||
while thread.instances:
|
instance = thread.instances.pop()
|
||||||
instance = thread.instances.pop()
|
if action:
|
||||||
if action:
|
if callable(action):
|
||||||
getattr(instance, action)()
|
action(instance)
|
||||||
# ## if you want pools, recycle this connection
|
else:
|
||||||
really = True
|
getattr(instance, action)()
|
||||||
if instance.pool_size:
|
# ## if you want pools, recycle this connection
|
||||||
sql_locker.acquire()
|
really = True
|
||||||
pool = ConnectionPool.pools[instance.uri]
|
if instance.pool_size:
|
||||||
if len(pool) < instance.pool_size:
|
sql_locker.acquire()
|
||||||
pool.append(instance.connection)
|
pool = ConnectionPool.pools[instance.uri]
|
||||||
really = False
|
if len(pool) < instance.pool_size:
|
||||||
sql_locker.release()
|
pool.append(instance.connection)
|
||||||
if really:
|
really = False
|
||||||
getattr(instance, 'close')()
|
sql_locker.release()
|
||||||
|
if really:
|
||||||
|
getattr(instance, 'close')()
|
||||||
|
|
||||||
|
if callable(action):
|
||||||
|
action(None)
|
||||||
return
|
return
|
||||||
|
|
||||||
def find_or_make_work_folder(self):
|
def find_or_make_work_folder(self):
|
||||||
|
|||||||
+4
-2
@@ -515,8 +515,10 @@ def wsgibase(environ, responder):
|
|||||||
|
|
||||||
if response.do_not_commit is True:
|
if response.do_not_commit is True:
|
||||||
BaseAdapter.close_all_instances(None)
|
BaseAdapter.close_all_instances(None)
|
||||||
elif response._custom_commit:
|
# elif response._custom_commit:
|
||||||
response._custom_commit()
|
# response._custom_commit()
|
||||||
|
elif response.custom_commit:
|
||||||
|
BaseAdapter.close_all_instances(response.custom_commit)
|
||||||
else:
|
else:
|
||||||
BaseAdapter.close_all_instances('commit')
|
BaseAdapter.close_all_instances('commit')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user