Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
take care of race conditions and close connection and request correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jfroche committed Oct 18, 2010
1 parent 0773b9a commit 1881834
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/five/taskqueue/processor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from zExceptions import NotFound
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
import ZPublisher
Expand Down Expand Up @@ -34,15 +35,19 @@ def call(self, method, args=(), errorValue=ERROR_MARKER):
try:
try:
ZPublisher.Publish.publish(request, 'Zope2', [None])
result = request.response.body
except NotFound, error:
log.warning('NotFound when traversing to %s' % '/'.join(path))
result = ''
except Exception, error:
# This thread should never crash, thus a blank except
log.error('Processor: ``%s()`` caused an error!' % method)
log.exception(error)
return errorValue is ERROR_MARKER and error or errorValue
result = errorValue is ERROR_MARKER and error or errorValue
finally:
request.close()
conn.close()
return request.response.body
return result


class SimpleProcessor(Z2PublisherMixin, BaseSimpleProcessor):
Expand Down

0 comments on commit 1881834

Please sign in to comment.