[Web-SIG] Closing long-running WSGI requests (possible?)

Christian Wyglendowski christian at dowski.com
Mon Apr 13 16:53:10 CEST 2009


On Mon, Apr 13, 2009 at 10:40 AM, Chimezie Ogbuji <ogbujic at ccf.org> wrote:
> Hello.  I have a problem with a WSGI-based SPARQL server that I have been
> unable to resolve for some time.  I was told this is the best place to ask
> :).  I'm building a SPARQL [1] server that is deployed as  WSGI/Paste
> server.  SPARQL queries are handled by the server and evaluated against a
> MySQL database using mysql-python/MySQLdb to manage the connection.
>
> My goal is to be able to allow clients to close the connection in order to
> kill queries that have been dispatched (in order to 'abort' them).

This should be doable from what I understand.  From PEP 333:

"If the iterable returned by the application has a close() method, the
server or gateway must call that method upon completion of the current
request, whether the request was completed normally, or terminated
early due to an error. (This is to support resource release by the
application. This protocol is intended to complement PEP 325's
generator support, and other common iterables with close() methods."
[1]

So it sounds like you could add a close method on whatever iterable
that your application returns and have it do the required resource
release there.

HTH,

Christian
http://www.dowski.com

[1] http://www.python.org/dev/peps/pep-0333/#specification-details


More information about the Web-SIG mailing list