Skip to content

Commit

Permalink
Remove selectors backport (#1358)
Browse files Browse the repository at this point in the history
* Implement wait_for_[read,write} directly on top of 'select' module

Our vendored backport of the 'selectors' module is huge, its tests are
flaky, and the only we thing we use it for is to... turn around and
implement some trivial select() operations. It lets urllib3 use epoll
or kqueue... but the way urllib3 uses them, they're actually *less*
efficient than just using poll or select.

This commit removes the dependency on 'selectors', by implementing
urllib3's wait_for_{read,write} helpers directly on top of
poll/select. Because I'm sneaky, it does this in terms of a more
generic wait_for_socket(...) operation, which is exactly the primitive
that we need for the bleach-spike branch (see gh-1323), so this should
also help keep the diff down.

* Delete selectors backport

Now that we're not using it anymore (see previous commit), it can be deleted.

* Address comments from review

- Check that poll works before using it
- Add a test for detecting readability after the peer closes the
  socket
- Remove an unnecessary coverage-control comment

* Delay choice of wait_for_socket backend until first call

To work around things like:

    import urllib3
    from gevent import monkey
    monkey.patch_all()

Since this means we no longer make an import-time decision about
wait_for_socket support, I also got rid of the constant
HAS_WAIT_FOR_SOCKET.

* Add test for calling wait_for_socket on a closed socket

* Fix lint errors
  • Loading branch information
njsmith authored and Jon Wayne Parrott committed Apr 20, 2018
1 parent 45a39bc commit 9782e1f
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 1,521 deletions.

0 comments on commit 9782e1f

Please sign in to comment.