Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR:aiohttp.web:Error handling request #25

Closed
wsshopping opened this issue Jul 23, 2015 · 7 comments · Fixed by #27
Closed

ERROR:aiohttp.web:Error handling request #25

wsshopping opened this issue Jul 23, 2015 · 7 comments · Fixed by #27

Comments

@wsshopping
Copy link

in my case,i use aiomysql for my httpserver,everything is running OK,but it raised a error after a day, more details as fallow:

INFO:root:SQL: select `id`, `rmdposter` from `video` where rmdposter<>''
ERROR:aiohttp.web:Error handling request
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/connection.py", line 466, in _read_packet
    packet_header = yield from self._reader.readexactly(4)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/asyncio/streams.py", line 482, in readexactly
    raise IncompleteReadError(partial, len(partial) + n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 4 expected bytes

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

Traceback (most recent call last):
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiohttp/server.py", line 272, in start
    yield from self.handle_request(message, payload)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiohttp/web.py", line 84, in handle_request
    resp = yield from handler(request)
  File "./app.py", line 30, in logger
    return (yield from handler(request))
  File "./app.py", line 38, in response
    r = yield from handler(request)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/diskb/dxb/code/python-webapp/httpserver/coroweb.py", line 139, in __call__
    r = yield from self._func(**kw)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/diskb/dxb/code/python-webapp/httpserver/handlers.py", line 89, in api_get_media_recommend
    dataList = yield from Media.getAssetRecommend("rmdposter<>'' ",args=None, type='index')
  File "/diskb/dxb/code/python-webapp/httpserver/orm.py", line 239, in getAssetRecommend
    rs = yield from select(' '.join(sql), args)
  File "/diskb/dxb/code/python-webapp/httpserver/orm.py", line 36, in select
    yield from cur.execute(sql.replace('?', '%s'), args or ())
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/cursors.py", line 223, in execute
    yield from self._query(query)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/cursors.py", line 444, in _query
    yield from conn.query(q)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/connection.py", line 357, in query
    yield from self._read_query_result(unbuffered=unbuffered)
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/connection.py", line 497, in _read_query_result
    yield from result.read()
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/connection.py", line 688, in read
    first_packet = yield from self.connection._read_packet()
  File "/root/.pyenv/versions/3.4.3/lib/python3.4/site-packages/aiomysql/connection.py", line 477, in _read_packet
    raise OperationalError(2006, msg % (exc,)) from exc
pymysql.err.OperationalError: (2006, 'MySQL server has gone away (0 bytes read on a total of 4 expected bytes)')

it seems that because of aiomysql , after i restart my case, everythig is OK, how can i fix it?

@jettify
Copy link
Member

jettify commented Jul 23, 2015

Thanks for report! Looks like this problem related to #16 . MySQL server has connection timeout, we should drop such connections gracefully in connection pool. In order confirm the cause you could change connection timeout in your my.cnf.

Would you like to propose PR?

@wsshopping
Copy link
Author

yeah, that's(MySQL server has connection timeout) exactly the reason in my case, but it seems not to be fixed in latest version? and the PR is undering test.

@asvetlov
Copy link
Member

See also stack overflow issue

@wsshopping
Copy link
Author

thank you

@NiaNingXue
Copy link

@wsshopping I hava the same problem ,how do you solve it?

@jettify
Copy link
Member

jettify commented Aug 31, 2015

I will make fix soon.

@jettify
Copy link
Member

jettify commented Sep 6, 2015

fixed via #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants