I am new to Python and Faust. We are using Faust.web to develop our APIs. Everything seems to be working except exceptions.
Problem is, when we run API server and hit a API from Postman that results in exception in our code, we correctly get 500 status code. But when we hit the same API next time, Postman waits for the response until API times out.
@configurations.route(somevalue + '/{document_id}')
class SomeAPI(BaseView):
async def put(self, request: Request, document_id: str) -> Response:
try:
a = 10/0
except Exception as e:
logger.error(f'Error while handling PUT Request: {request}, Error: {e}', exc_info=True)
return self.json(value=HttpError.INTERNAL_SERVER_ERROR.value, status=500,
headers=self.response_headers)
else:
return self.json(value=result, status=200, headers=self.response_headers)
Please Help!
Try casting your catched exception to string:
Alternatively you can make use of
logger.exception()
.