Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize ERROR_INVALID_HANDLE as indicating the IOCP was closed #86

Merged
merged 1 commit into from
Mar 13, 2017

Conversation

njsmith
Copy link
Member

@njsmith njsmith commented Mar 11, 2017

There's a race condition when we signal the IOCP thread to exit by
closing the IOCP: the thread might be blocked in
GetQueuedCompletionStatusEx, or it might (rarely) be in the rest of
the loop. The effect of this is that there are two possible error
messages we might get that both indicate that the IOCP was
closed. Before we were only detecting one of them; now we detect
both.

This has the side-effect of making it so that during the test suite we
deterministically only take the regular-exit path, rather than
sometimes taking the blow-up-on-unrecognized-error path. Which is
good because codecov was getting cranky about that non-deterministic
coverage and yelling at people for no reason (see gh-81).

There's a race condition when we signal the IOCP thread to exit by
closing the IOCP: the thread might be blocked in
GetQueuedCompletionStatusEx, or it might (rarely) be in the rest of
the loop. The effect of this is that there are two possible error
messages we might get that both indicate that the IOCP was
closed. Before we were only detecting one of them; now we detect
both.

This has the side-effect of making it so that during the test suite we
deterministically only take the regular-exit path, rather than
sometimes taking the blow-up-on-unrecognized-error path. Which is
good because codecov was getting cranky about that non-deterministic
coverage and yelling at people for no reason (see python-triogh-81).
@njsmith
Copy link
Member Author

njsmith commented Mar 11, 2017

@brettcannon: hopefully this should fix the codecov thing - any interest in reviewing?

@codecov-io
Copy link

Codecov Report

Merging #86 into master will decrease coverage by 0.05%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master      #86      +/-   ##
==========================================
- Coverage   98.29%   98.24%   -0.06%     
==========================================
  Files          50       50              
  Lines        5876     5878       +2     
  Branches      464      464              
==========================================
- Hits         5776     5775       -1     
- Misses         86       88       +2     
- Partials       14       15       +1
Impacted Files Coverage Δ
trio/_core/_windows_cffi.py 91.3% <100%> (+0.39%)
trio/_core/_io_windows.py 75.14% <50%> (-1.6%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08bf8b6...cd8bdc2. Read the comment docs.

Copy link
Contributor

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have zero IOCP experience, but LGTM. 😄

# signal that it should shut down, the main thread just closes the
# IOCP, which causes GetQueuedCompletionStatusEx to return with an
# error:
IOCP_CLOSED_ERRORS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this constant is a local and not a global?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, could go either way, but I feel like the category being defined here is more specific to the semantics of this particular function than something that's generally meaningful.

@njsmith
Copy link
Member Author

njsmith commented Mar 13, 2017

I have zero IOCP experience, but LGTM. 😄

Then you're in the same boat as me :-)

@njsmith njsmith merged commit 1682e71 into python-trio:master Mar 13, 2017
@njsmith njsmith deleted the iocp-deterministic-coverage branch March 13, 2017 20:39
@njsmith
Copy link
Member Author

njsmith commented Mar 13, 2017

@brettcannon: btw, want to be added as a collaborator? (Can you tell I'm eager to get more folks involved 😄)

@brettcannon
Copy link
Contributor

Sure, but I make no promises I will ever use such powers. 😁

@njsmith
Copy link
Member Author

njsmith commented Mar 14, 2017

That's fair :-). You should have an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants