Preserve file descriptor blocking mode in add_reader and add_writer - #761
Open
HyunsikParker wants to merge 1 commit into
Open
Preserve file descriptor blocking mode in add_reader and add_writer#761HyunsikParker wants to merge 1 commit into
HyunsikParker wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #712.
libuv's
uv_poll_init()switches the supplied file descriptor to nonblocking mode. uvloop left that change in place afteradd_reader()oradd_writer(), while the asyncio selector loop preserves the original mode.This records the mode before initializing the poll handle and restores it once initialization finishes. If restoring it fails, the initialized handle is closed before the error is raised.
The regression test covers reader and writer registration and checks the descriptor both while registered and after removal. The same test runs against uvloop and the asyncio reference loop.
Tests:
.venv/bin/python -m unittest -v tests.test_sockets(35 passed, 1 skipped)test_fs_event_renameexcluded, 528 tests passed withPYTHONASYNCIODEBUG=1and again withPYTHONASYNCIODEBUG=0(39 skipped in each run)test_fs_event_renamefailure. Isolated reruns produced one pass and oneCHANGEversusRENAMEfailure.