Skip to content

ValueError: list.remove(x): x not in list #670

@dimaqq

Description

@dimaqq

Apologies for a not-very-well-formed bug report.

I was only able to hit this under rather weird conditions (streaming responses, backpressure, connection pool full).

ERROR:hypercorn.error:Error in ASGI Framework
Traceback (most recent call last):
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 227, in handle_async_request
    connection = await status.wait_for_connection(timeout=timeout)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 34, in wait_for_connection
    await self._connection_acquired.wait(timeout=timeout)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpcore/_synchronization.py", line 38, in wait
    await self._event.wait()
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1842, in wait
    if await self._event.wait():
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 23, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/hypercorn/app_wrappers.py", line 33, in __call__
    await self.app(scope, receive, send)
  File "/home/proxy/proxy/app.py", line 119, in app
    async with config.upstream_client.stream(
  File "/usr/local/lib/python3.10/contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1570, in stream
    response = await self.send(
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1614, in send
    response = await self._send_handling_auth(
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1642, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1679, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 1716, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/home/proxy/.cache/pypoetry/virtualenvs/proxy-9E6wT_fw-py3.10/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 233, in handle_async_request
    self._requests.remove(status)
ValueError: list.remove(x): x not in list

At the very end, when httpcore fails here:

except BaseException as exc:
# If we timeout here, or if the task is cancelled, then make
# sure to remove the request from the queue before bubbling
# up the exception.
async with self._pool_lock:
self._requests.remove(status)
raise exc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions