Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Fixed: should release when connection is closed, not at end of request.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Sep 10, 2013
1 parent 9843116 commit a3cbc01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/zc/zodbwsgi/README.rst
Expand Up @@ -709,8 +709,6 @@ complete.
>>> import sys
>>> def app(environ, start_response):
... print 'about to close'
... environ['zodb.connection'].onCloseCallback(
... lambda : sys.stdout.write('close\n'))
... environ['zodb.connection'].close()
... print 'closed'
... start_response('200 OK', [])
Expand All @@ -737,9 +735,8 @@ complete.
acquire
begin
about to close
close
closed
release
closed
Dealing with the occasional long-running requests
-------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion src/zc/zodbwsgi/__init__.py
Expand Up @@ -127,6 +127,7 @@ def __call__(self, environ, start_response):
@conn.onCloseCallback
def on_close():
closed.append(1)
self.release()

try:
try:
Expand All @@ -146,7 +147,8 @@ def on_close():
del environ[self.transaction_key]
del environ[self.key]
finally:
self.release()
if not closed:
self.release()

else:
try:
Expand Down

0 comments on commit a3cbc01

Please sign in to comment.