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

RuntimeError: readuntil() called while another coroutine is already waiting for incoming data #2540

Closed
Tiendil opened this issue Jan 4, 2023 · 2 comments
Labels

Comments

@Tiendil
Copy link

Tiendil commented Jan 4, 2023

Version: redis==4.4.0, Redis: redis:6.2-alpine (docker)

Platform: Python 3.9.16, docker python:3.9

Description: Redis client raises RuntimeError while doing multiple concurrency operations.

Reproduced on 4.4.0, ok on 4.3.5

Example code:

import asyncio
import uuid

from redis.asyncio import Redis


async def main():

    client = Redis(
        host="redis",
        port=6379,
        db=0,
        username=None,
        password=None,
        retry_on_timeout=True,
        single_connection_client=True,
        client_name='test_client',
    )

    # At my PC stable reproduces with n=10, but let set n=100 for better guarantees
    n = 100

    async def problem():
        await client.delete(uuid.uuid4().hex)
        await client.delete(uuid.uuid4().hex)  # <- problem is at this line

    operations = [problem() for i in range(n)]

    await asyncio.gather(*operations)

    print('success!')

Stacktrace:

Traceback (most recent call last):
  File "/app/x.py", line 36, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/x.py", line 33, in main
    await asyncio.gather(*operations)
  File "/app/x.py", line 29, in problem
    await client.delete(uuid.uuid4().hex)  # <- problem is at this line
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 505, in execute_command
    return await conn.retry.call_with_retry(
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/retry.py", line 59, in call_with_retry
    return await do()
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 481, in _send_command_parse_response
    return await self.parse_response(conn, command_name, **options)
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/client.py", line 524, in parse_response
    response = await connection.read_response()
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/connection.py", line 800, in read_response
    response = await self._parser.read_response(
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/connection.py", line 245, in read_response
    raw = await self._readline()
  File "/tmp/venv/lib/python3.9/site-packages/redis/asyncio/connection.py", line 311, in _readline
    data = await self._stream.readline()
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 540, in readline
    line = await self.readuntil(sep)
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 632, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.9/asyncio/streams.py", line 503, in _wait_for_data
    raise RuntimeError(
RuntimeError: readuntil() called while another coroutine is already waiting for incoming data
@dvora-h
Copy link
Collaborator

dvora-h commented Jan 29, 2023

Fixed in #2568

@dvora-h dvora-h closed this as completed Jan 29, 2023
@iwpnd
Copy link

iwpnd commented Feb 7, 2023

update: created a separate issue

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

No branches or pull requests

3 participants