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

Catching connection lost on _write_bytes #453

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andr-04
Copy link

@andr-04 andr-04 commented Dec 2, 2019

It's possible the connection can dropping without any notification. There was caught the connection lost while making a request to MySQL through peewee_async:

Traceback (most recent call last):
...
  File "/usr/lib/python3.6/site-packages/peewee_async.py", line 1441, in _run_sql
    await cursor.execute(operation, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/aiomysql/cursors.py", line 237, in execute
    await self._query(query)
  File "/usr/lib/python3.6/site-packages/aiomysql/cursors.py", line 455, in _query
    await conn.query(q)
  File "/usr/lib/python3.6/site-packages/aiomysql/connection.py", line 419, in query
    await self._execute_command(COMMAND.COM_QUERY, sql)
  File "/usr/lib/python3.6/site-packages/aiomysql/connection.py", line 648, in _execute_command
    self._write_bytes(prelude + sql[:chunk_size - 1])
  File "/usr/lib/python3.6/site-packages/aiomysql/connection.py", line 593, in _write_bytes
    return self._writer.write(data)
  File "/usr/lib/python3.6/asyncio/streams.py", line 300, in write
    self._transport.write(data)
  File "uvloop/handles/stream.pyx", line 671, in uvloop.loop.UVStream.write
  File "uvloop/handles/handle.pyx", line 159, in uvloop.loop.UVHandle._ensure_alive
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x2742598>; the handler is closed

Because of the connection remains in a wrong state (self._writer.transport.closed == True, but self.closed == False), it is put to the pool again on release().

@terricain
Copy link
Collaborator

👍

andr-04 added 2 commits May 18, 2021 14:51
* commit '0a8af2355562ea961477738d66b3334332447186':
  Bump version and tweak setup.py (aio-libs#540)
  Fill changelog for 0.0.21 release (aio-libs#538)
  Support python 3.7 and 3.8 in tests and travis CI
  Update dependencies (aio-libs#485)
  chore(flake8): fixed flake8 errors (aio-libs#484)
  added support for sqlalchemy default parameters aio-libs#455 (aio-libs#456)
  Fix flake
  Fixed invalid datatime for MySQL 5.7
  Rewrote tests to use pytest exclusively
  Fixed linting
  Attempted to move db completely to docker
  Fix Travis attempt 1
  Fix aio-libs#454
* commit '8a32f052a16dc3886af54b98f4d91d95862bfb8e': (92 commits)
  Update changelog for 0.1.1 release (aio-libs#784)
  Bump pytest from 7.1.1 to 7.1.2 (aio-libs#781)
  XFail test_issue_36 for now to avoid failing for unrelated changes (aio-libs#779)
  Skip codecov uploads in scheduled daily tests (aio-libs#778)
  Bump codecov/codecov-action from 3.0.0 to 3.1.0 (aio-libs#777)
  Fix SSL connection handshake charset not respecting client configuration (aio-libs#776)
  Bump ncipollo/release-action from 1.9.0 to 1.10.0 (aio-libs#766)
  Bump actions/cache from 3.0.1 to 3.0.2 (aio-libs#771)
  Bump actions/download-artifact from 2 to 3 (aio-libs#765)
  Bump actions/upload-artifact from 2 to 3 (aio-libs#767)
  Update changelog for release (aio-libs#769)
  Checkout git source to access changelog for GitHub release creation
  Change next version to 0.1.0 in changelog
  Fix GHA badge in readme after aio-libs#734 (aio-libs#762)
  Fix SSCursor raising query timeout error on wrong query on MySQL DB (aio-libs#761)
  Specify explicit language for literal blocks in CONTRIBUTING.rst to reduce warnings in doc builds (aio-libs#760)
  fix `make checkrst` (aio-libs#759)
  Update sphinx requirement from <4.4.1,>=1.8.1 to 4.5.0 (aio-libs#751)
  Bump codecov/codecov-action from 2.1.0 to 3.0.0 (aio-libs#758)
  Bump actions/cache from 2.1.7 to 3.0.1 (aio-libs#752)
  ...
@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #453 (b67267d) into master (8a32f05) will decrease coverage by 0.03%.
The diff coverage is 55.55%.

@@            Coverage Diff             @@
##           master     #453      +/-   ##
==========================================
- Coverage   92.72%   92.69%   -0.04%     
==========================================
  Files          38       38              
  Lines        5569     5571       +2     
  Branches      943      942       -1     
==========================================
  Hits         5164     5164              
- Misses        317      320       +3     
+ Partials       88       87       -1     
Flag Coverage Δ
ubuntu-latest_3.10_mariadb-10.2 89.24% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mariadb-10.3 89.24% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mariadb-10.4 89.24% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mariadb-10.5 89.22% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mariadb-10.6 89.22% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mariadb-10.7 89.22% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mysql-5.7 89.92% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.10_mysql-8.0 91.31% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.2 89.21% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.3 89.21% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.4 89.21% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.5 89.19% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.6 89.19% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mariadb-10.7 89.19% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mysql-5.7 89.89% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.11-dev_mysql-8.0 91.27% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.2 88.64% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.3 88.64% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.4 88.64% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.5 88.62% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.6 88.62% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mariadb-10.7 88.62% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mysql-5.7 89.36% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.7_mysql-8.0 90.83% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.2 89.28% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.3 89.28% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.4 89.28% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.5 89.27% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.6 89.27% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mariadb-10.7 89.27% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mysql-5.7 89.97% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.8_mysql-8.0 91.33% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.2 89.14% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.3 89.14% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.4 89.14% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.5 89.12% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.6 89.12% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mariadb-10.7 89.12% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mysql-5.7 89.82% <55.55%> (-0.04%) ⬇️
ubuntu-latest_3.9_mysql-8.0 91.19% <55.55%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiomysql/connection.py 83.78% <42.85%> (-0.20%) ⬇️
aiomysql/pool.py 97.04% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a32f05...b67267d. Read the comment docs.

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

Successfully merging this pull request may close these issues.

3 participants