You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
select.poll() is not available when using eventlet #327
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.
This seems to do it pretty reliably. Increasing the loop count causes the connection pool to get used up which triggers the problem:
eventlet.monkey_patch()
import httpx
client = httpx.Client()
for x in range(1, 10):
client.get('http://www.google.com')
Traceback (most recent call last):
File "/home/bobh/testhttpcore.py", line 9, in <module>
client.get('http://www.google.com')
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 975, in get
return self.request(
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 747, in request
return self.send(
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 831, in send
response = self._send_handling_auth(
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 866, in _send_handling_auth
response = self._send_handling_redirects(
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 900, in _send_handling_redirects
response = self._send_single_request(request, timeout)
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/lib/python3.8/site-packages/httpx/_client.py", line 934, in _send_single_request
(status_code, headers, stream, extensions) = transport.handle_request(
File "/home/bobh/PyCharmProjects/python-backend/.tox/dev/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 "/home/bobh/git/httpcore/httpcore/_sync/http_proxy.py", line 115, in handle_request
return self._forward_request(
File "/home/bobh/git/httpcore/httpcore/_sync/http_proxy.py", line 145, in _forward_request
connection = self._get_connection_from_pool(origin)
File "/home/bobh/git/httpcore/httpcore/_sync/connection_pool.py", line 254, in _get_connection_from_pool
if connection.is_socket_readable():
File "/home/bobh/git/httpcore/httpcore/_sync/connection.py", line 172, in is_socket_readable
return self.connection is not None and self.connection.is_socket_readable()
File "/home/bobh/git/httpcore/httpcore/_sync/http11.py", line 212, in is_socket_readable
return self.socket.is_readable()
File "/home/bobh/git/httpcore/httpcore/_backends/sync.py", line 82, in is_readable
return is_socket_readable(self.sock)
File "/home/bobh/git/httpcore/httpcore/_utils.py", line 103, in is_socket_readable
p = select.poll()
AttributeError: module 'select' has no attribute 'poll'
Activity
lovelydinosaur commentedon May 3, 2021
Could you provide a minimal example that can be used to reproduce this?
bobh66 commentedon May 3, 2021
This seems to do it pretty reliably. Increasing the loop count causes the connection pool to get used up which triggers the problem:
Use select.select when select.poll is not available (encode#327)
Use select.select when select.poll is not available (#327) (#331)