Discuss / Python / 点击注册后页面出现:网络好像出问题了 (HTTP 500)

点击注册后页面出现:网络好像出问题了 (HTTP 500)

Topic source

bubu_ka

#1 Created at ... [Delete] [Delete and Lock User]

我按照廖老师的教程,想注册一个用户名后点击提交有错误,希望帮我解决一下: 点击后页面出现:网络好像出问题了 (HTTP 500)

awesome-python3-webapp/www/handlers.py:126: RuntimeWarning: coroutine 'Model.findAll' was never awaited users = yield from User.findAll('email=?', [email]) ERROR:aiohttp.server:Error handling request Traceback (most recent call last): File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 417, in start resp = yield from self._request_handler(request) File "/anaconda3/lib/python3.6/site-packages/aiohttp/web.py", line 289, in _handle resp = yield from handler(request) File "app.py", line 43, in logger return (await handler(request)) File "app.py", line 61, in response r = await handler(request) File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_urldispatcher.py", line 111, in handler_wrapper result = yield from result File "/Users/k.den/awesome-python3-webapp/www/coroweb.py", line 136, in call r = yield from self._func(**kw) File "/anaconda3/lib/python3.6/asyncio/coroutines.py", line 213, in coro res = yield from res File "/Users/k.den/awesome-python3-webapp/www/handlers.py", line 126, in api_register_user users = yield from User.findAll('email=?', [email]) TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator INFO:aiohttp.access:127.0.0.1 - - [14/Dec/2017:04:08:16 +0000] "POST /api/users HTTP/1.1" 500 330 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8

bubu_ka

#2 Created at ... [Delete] [Delete and Lock User]

解决了,关键是这个话:TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator。 我用了yield from 改成await就可以


  • 1

Reply