aio-libs / aiomysql

aiomysql is a library for accessing a MySQL database from the asyncio
https://aiomysql.rtfd.io
MIT License
1.76k stars 257 forks source link

RuntimeError: readexactly() called while another coroutine is already waiting for incoming data #277

Closed chayleaf closed 6 years ago

chayleaf commented 6 years ago
  File "C:\Python36-32\lib\site-packages\aiomysql\cursors.py", line 240, in execute
    yield from self._query(query)
  File "C:\Python36-32\lib\site-packages\aiomysql\cursors.py", line 461, in _query
    yield from conn.query(q)
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 403, in query
    yield from self._read_query_result(unbuffered=unbuffered)
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 597, in _read_query_result
    yield from result.read()
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 850, in read
    first_packet = yield from self.connection._read_packet()
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 535, in _read_packet
    packet_header = yield from self._read_bytes(4)
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 573, in _read_bytes
    data = yield from self._reader.readexactly(num_bytes)
  File "C:\Python36-32\lib\asyncio\streams.py", line 668, in readexactly
    yield from self._wait_for_data('readexactly')
  File "C:\Python36-32\lib\asyncio\streams.py", line 446, in _wait_for_data
    'already waiting for incoming data' % func_name)
RuntimeError: readexactly() called while another coroutine is already waiting for incoming data

python 3.6 aiomysql 0.0.12 windows 7 x64

chayleaf commented 6 years ago

got another cryptic error

  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 334, in c
ommit
    yield from self._read_ok_packet()
  File "C:\Python36-32\lib\site-packages\aiomysql\connection.py", line 311, in _
read_ok_packet
    raise OperationalError(2014, "Command Out of Sync")
pymysql.err.OperationalError: (2014, 'Command Out of Sync')
chayleaf commented 6 years ago

apparently fixed by using semaphores, still I'd like to get an explanation of what's going on

chayleaf commented 6 years ago

never mind, apparently mysql only supports 1 connection. How about adding a semaphore to the lib then?

jettify commented 6 years ago

We have connection pool to benefit from multiple connections instead of one.

chayleaf commented 6 years ago

thanks, will check it out