-
Notifications
You must be signed in to change notification settings - Fork 259
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
unable to perform operation on <TCPTransport closed=True reading=False 0x1e41248>; the handler is closed` #195
Comments
I encounter this problem too, so I add an retry logic to fix it temporarily, you can try my patch. |
sorry,i can't this file. |
diff --git a/aiomysql/sa/connection.py b/aiomysql/sa/connection.py
index 9cc8520..89cb5a6 100644
--- a/aiomysql/sa/connection.py
+++ b/aiomysql/sa/connection.py
@@ -3,9 +3,10 @@
import asyncio
import weakref
+import pymysql
from sqlalchemy.sql import ClauseElement
-from sqlalchemy.sql.dml import UpdateBase
from sqlalchemy.sql.ddl import DDLElement
+from sqlalchemy.sql.dml import UpdateBase
from . import exc
from .result import create_result_proxy
@@ -104,7 +105,11 @@ class SAConnection:
raise exc.ArgumentError("Don't mix sqlalchemy DDL clause "
"and execution with parameters")
post_processed_params = [compiled.construct_params()]
- yield from cursor.execute(str(compiled), post_processed_params[0])
+ try:
+ yield from cursor.execute(str(compiled), post_processed_params[0])
+ except pymysql.err.OperationalError:
+ yield from self._connection.ping()
+ yield from cursor.execute(str(compiled), post_processed_params[0])
else:
raise exc.ArgumentError("sql statement should be str or "
"SQLAlchemy data "
patch is here |
folowing
added a commit
to folowing/aiomysql
that referenced
this issue
Aug 12, 2018
This looks like the same problem I encountered and fixed in #339 (my traceback is different because we're not using In both cases it appears the connection is closed by the server or a TCP timeout while it's in the pool. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,i use
python3.5.3
aiohttp 2.0.7
aiomysql 0.0.9
sqlalchemy1.1.10
When i open the application for a long time.Throw the following error
2017-07-27 10:28:13 rtgroom.py[line:141] ERROR Traceback (most recent call last): File "/home/wwwroot/ykrealtime/rtgame/models/mysql/rtgroom.py", line 137, in get_invite_me_count RTG_room.select().where(RTG_room.c.create_by == create_by).where(RTG_room.c.status == 1)) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/utils.py", line 66, in __await__ resp = yield from self._coro File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/sa/connection.py", line 107, in _execute yield from cursor.execute(str(compiled), post_processed_params[0]) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/cursors.py", line 239, in execute yield from self._query(query) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/cursors.py", line 460, in _query yield from conn.query(q) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/connection.py", line 397, in query yield from self._execute_command(COMMAND.COM_QUERY, sql) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/connection.py", line 627, in _execute_command self._write_bytes(prelude + sql[:chunk_size - 1]) File "/home/wwwroot/ykrealtime/venv/lib/python3.5/site-packages/aiomysql/connection.py", line 568, in _write_bytes return self._writer.write(data) File "/usr/local/lib/python3.5/asyncio/streams.py", line 294, in write self._transport.write(data) File "uvloop/handles/stream.pyx", line 632, in uvloop.loop.UVStream.write (uvloop/loop.c:74612) File "uvloop/handles/handle.pyx", line 150, in uvloop.loop.UVHandle._ensure_alive (uvloop/loop.c:54917) RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x1e41248>; the handler is closed
The text was updated successfully, but these errors were encountered: