Skip to content

Implement overlapped I/O and timeouts on server side Windows IPC #6148

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

Merged
merged 13 commits into from
Jan 8, 2019

Conversation

emmatyping
Copy link
Member

@emmatyping emmatyping commented Jan 5, 2019

This PR does a few things:

  • Changes reads/writes/connects to use overlapped I/O on Windows
  • Removes the need for special casing b'' as an EOF signal
  • Adds support for timing out on connects for the server process (which means dmypy's --timeout flag works on Windows).
  • Make the default timeout infinite (though this doesn't change anything functionally since we always specify alternatives in our usage)

Note that sadly this will fail self type checking (edit: on Windows) since their signatures in typeshed are for the non-overlapped versions (I will be making a PR to typeshed soon PR here: python/typeshed#2723). (The PR is merged and synced). The PR ended up relaxing the return types, so I added some asserts for greater type safety.

A lot of the overlapped I/O is based on the docs and https://github.com/python/cpython/blob/master/Lib/multiprocessing/connection.py. The main difference is the timeouts and I used WaitForSingleObject, since that seems sufficient for our purposes.

Fixes #5962

@emmatyping emmatyping requested a review from msullivan January 5, 2019 08:50
srittau pushed a commit to python/typeshed that referenced this pull request Jan 7, 2019
@emmatyping emmatyping mentioned this pull request Jan 7, 2019
emmatyping added a commit that referenced this pull request Jan 7, 2019
With updates to _winapi for #6148.
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Great!

@emmatyping emmatyping merged commit 41562a0 into python:master Jan 8, 2019
@emmatyping emmatyping deleted the overlappedio branch January 8, 2019 22:28
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
hauntsaninja pushed a commit that referenced this pull request Nov 1, 2022
As per the TODO comments, this PR removes some unnecessary `assert`s in
`mypy/ipc.py`. When these `assert`s were added in #6148, typeshed wasn't
able to use `Literal` types yet. However, nowadays, typeshed has precise
`Literal` overloads for `_winapi.WriteFile` and
`_winapi.ConnectNamedType`, meaning mypy is able to precisely infer the
return type of these function calls without the need for the `assert`s
in `mypy/ipc.py`:
https://github.com/python/typeshed/blob/main/stdlib/_winapi.pyi.
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