squeaky-pl/japronto

Unhandled exception in event loop

hanymorcos opened this issue · 3 comments

Is that on the list of issues?

wrk -t12 -c400 -d30s

versions/3.6.9/lib/python3.6/site-packages/japronto/app/init.py", line 86, in default_error_handler
text=tb if self._debug else 'Internal Server Error')
RuntimeError: Request.Response can only be called once per request
ValueError: View did not return Response instance
Unhandled exception in event loop

You should change return type of your function to return a Response instance instead of anything else.

import random
from japronto import Application

def generaterandom(request):
number = random.randint(0, 100)
result = {'lowerLimit': 0, 'higherLimit': 100, 'number': number}
request.Response(json=result)

app = Application()
r = app.router
r.add_route('/number', generaterandom, method='GET')
app.run()

Is "json" not a valid return type?

I will try text.