[Zope] Detecting dropped client connection?
Dieter Maurer
dieter@handshake.de
Wed, 26 Sep 2001 21:58:10 +0200 (CEST)
Stuart Bishop writes:
> I have a method that generates a large database report (around 4MB).
> It takes around 5 minutes to generate, but I can happily stream it
> to the client using RESPONSE.write().
>
> What I have noticed, however, is that if the client drops the connection,
> my method just keeps processing oblivious wasting ram, cycles but most
> importantly a Zope thread. Is there a call I can make for my code to
> check
> if the connection is still valid, allowing it to die if nothing is
> listening to it?
Difficult....
The connection shutdown in recognized in a ZServer thread.
A series of producers is used to interface this thread with
the Zope thread.
You would need to enchance the producers with a method,
say "abortProcessing" which modifies the producer's state
such that when the Zope thread delivers data for the next
time, an exception is raised, aborting the thread execution.
Dieter