Skip to content

select.poll() is not available when using eventlet #327

Description

@bobh66

When using httpx/httpcore and eventlet together, is_socket_readable() fails with an AttributeError because poll() is not implemented in eventlet:

File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1130, in patch
    return self.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 747, in request
    return self.send(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 831, in send
    response = self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 866, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 900, in _send_handling_redirects
    response = self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 934, in _send_single_request
    (status_code, headers, stream, extensions) = transport.handle_request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 179, in handle_request
    status_code, headers, byte_stream, extensions = self._pool.handle_request(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 212, in handle_request
    connection = self._get_connection_from_pool(origin)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py", line 254, in _get_connection_from_pool
    if connection.is_socket_readable():
  File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/connection.py", line 172, in is_socket_readable
    return self.connection is not None and self.connection.is_socket_readable()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_sync/http11.py", line 215, in is_socket_readable
    return self.socket.is_readable()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/sync.py", line 82, in is_readable
    return is_socket_readable(self.sock)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_utils.py", line 102, in is_socket_readable
    p = select.poll()

Since this code already uses select.select() instead of select.poll() on Windows, I will push a PR to also use select.select() if poll() is unavailable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions