Skip to content

Rewrite IPC to use multiprocessing.connection - #6010

Closed
emmatyping wants to merge 4 commits into
python:masterfrom
emmatyping:multiprocessipc
Closed

emmatyping wants to merge 4 commits into
python:masterfrom
emmatyping:multiprocessipc

Conversation

@emmatyping

Copy link
Copy Markdown
Member

This re-writes the IPC module to use the communication primitives in multiprocessing.connection so we don't duplicate as much work. It also means we can replace out JSON serialization to passing objects (which should probably go in a separate PR).

In short, this makes IPC much more robust.

There are a few missing definitions and other issues in typeshed for multiprocessing.connection, I am planning on making a PR for that momentarily.

@emmatyping
emmatyping requested a review from msullivan December 5, 2018 06:50
@emmatyping

Copy link
Copy Markdown
Member Author

I think I will likely defer this till we figure out what is wrong with the daemon on Windows.

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(Not a full review.)

Comment thread mypy/dmypy_server.py
while True:
with server:
data = receive(server)
with server as connection:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These semantics of __enter__ are a little too magical. I'd prefer to see something like with server.accept_connection() as connection here.

Comment thread mypy/dmypy_server.py
# simplify the logic and always remove the file, since
# that could cause us to remove a future server's
# status file.)
server.close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sully had a specific reason for the ordering of the closing of the socket and the unlinking of the status file; if you close the socket first, it's possible for a new client to start a new server before we get to remove the status file, and then we'd end up removing the wrong status file. See #5956.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think in this case it is just cleanliness. The bug fix was doing the file removal in cmd_stop, before any response is sent.

@JukkaL

JukkaL commented Dec 5, 2018

Copy link
Copy Markdown
Collaborator

@ethanhs How important is this PR? In particular, do you think that it's okay to release mypy with official Windows dmypy support without this change, or should we wait until this is in?

@emmatyping

Copy link
Copy Markdown
Member Author

Ah, sorry I probably should have marked this WIP last night (but thank you for the feedback Guido).

@JukkaL I don't think this needs to be in the release. I am a bit concerned with releasing with #5983 dangling over our heads, but I'm also a bit stumped at the moment because I am having difficulty reproducing it and gaining any extra information.

@emmatyping

Copy link
Copy Markdown
Member Author

I think it isn't worth it to do this after all. We have to re-implement enough that I think it is easier to just keep our own implementation.

@emmatyping emmatyping closed this Dec 11, 2018
@emmatyping
emmatyping deleted the multiprocessipc branch January 31, 2019 02:31
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.

4 participants