MarkReedZ / mrhttp

The fastest python web framework - 8.5m requests per second!
MIT License
24 stars 6 forks source link

Bad error message if I forget to return from a page handler #6

Closed ShermanGirl closed 5 years ago

ShermanGirl commented 6 years ago

Maybe print the exception and return 500 or 404?

@app.route('/')
async def index(r):
    pass

Exception in callback <built-in method task_done of protocol.Protocol object at 0x2b6d770>
handle: <Handle Protocol.task_done>
ValueError: Page handler did not return a string

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 49, in uvloop.loop.Handle._run
SystemError: <built-in method write of uvloop.loop.TCPTransport object at 0x2a2d928> returned a result with an error set
MarkReedZ commented 6 years ago

We were setting the exception before sending back the 500 response to the client so we complained when the transport object returned successfully. Now it just looks like this:

Exception in callback <built-in method task_done of protocol.Protocol object at 0x2b6d770>
handle: <Handle Protocol.task_done>
ValueError: Page handler did not return a string

Leaving this issue open to review later. I'd like to just raise the exception without seeing the callback and handle lines. Also the ValueError should probably be a custom exception.

MarkReedZ commented 5 years ago

Closing this. The exception remains as above which I think is fine.