def _handle_request(self, request):
"""Handle *request*, return reply."""
if not isinstance(request, dict):
return self.error('invalid request: a dictionary is required.')
command = request.get('command')
if not command:
log.error('invalid request was %r', request)
return self.error('invalid request: no command.')
try:
reply = self.handle_request(request)
if reply is None:
log.error('invalid request was %r', request)
return self.error('invalid request: not handled')
return reply
except Exception as exc:
log.exception('Error during request processing. Request was %r', request)
if not isinstance(exc, zmq.ZMQError) and self.socket:
# Probably need to send a reply
return self.error('Uncaught exception during processing')
sys.exit(1)
评论列表
文章目录