def __process_request(self, stream, pid, timeout):
# Process request and get response stream.
# Request are processed inside a thread pool to avoid
# userland code to block requests.
res = self._pool.spawn(self.__process_request_stream, stream)
# Wait for a period of seconds to get the execution result
try:
response = res.get(timeout=timeout)
except gevent.Timeout:
msg = 'SDK execution timed out after {}ms'.format(
int(timeout * 1000),
pid,
)
response = create_error_response(msg)
LOG.warn('{}. PID: {}'.format(msg, pid))
except:
LOG.exception('Failed to handle request. PID: %d', pid)
response = create_error_response('Failed to handle request')
self._send_response(response)
评论列表
文章目录