Skip to content

Commit

Permalink
Prevent uncaught exceptions from killing ZServer worker threads.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Sep 1, 2010
1 parent b5890a9 commit e03a5f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions doc/CHANGES.txt
Expand Up @@ -8,6 +8,9 @@ Zope Changes

Bugs Fixed

- Prevent uncaught exceptions from killing ZServer worker threads.
https://bugs.launchpad.net/zope2/+bug/627988

- Ensure that mailhosts which share a queue directory do not double-
deliver mails, by sharing the thread which processes emails for
that directory. https://bugs.launchpad.net/zope2/+bug/574286
Expand Down
46 changes: 27 additions & 19 deletions lib/python/ZServer/PubCore/ZServerPublisher.py
Expand Up @@ -11,28 +11,36 @@
#
##############################################################################

import logging

LOG = logging.getLogger('ZServerPublisher')

class ZServerPublisher:
def __init__(self, accept):
from sys import exc_info
from ZPublisher import publish_module
from ZPublisher.WSGIPublisher import publish_module as publish_wsgi
while 1:
name, a, b=accept()
if name == "Zope2":
try:
publish_module(
name,
request=a,
response=b)
finally:
b._finish()
a=b=None
try:
name, a, b=accept()
if name == "Zope2":
try:
publish_module(
name,
request=a,
response=b)
finally:
b._finish()
a=b=None

elif name == "Zope2WSGI":
try:
res = publish_wsgi(a, b)
for r in res:
a['wsgi.output'].write(r)
finally:
# TODO: Support keeping connections open.
a['wsgi.output']._close = 1
a['wsgi.output'].close()
elif name == "Zope2WSGI":
try:
res = publish_wsgi(a, b)
for r in res:
a['wsgi.output'].write(r)
finally:
# TODO: Support keeping connections open.
a['wsgi.output']._close = 1
a['wsgi.output'].close()
except:
LOG.error('exception caught', exc_info=True)

0 comments on commit e03a5f0

Please sign in to comment.