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

Rewrite IPC to use multiprocessing.connection #6010

Closed
wants to merge 4 commits into from

Conversation

ethanhs
Copy link
Collaborator

@ethanhs ethanhs commented Dec 5, 2018

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.

@ethanhs
Copy link
Collaborator Author

ethanhs commented Dec 5, 2018

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

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.

(Not a full review.)

@@ -200,8 +200,8 @@ def serve(self) -> None:
json.dump({'pid': os.getpid(), 'connection_name': server.connection_name}, f)
f.write('\n') # I like my JSON with a trailing newline
while True:
with server:
data = receive(server)
with server as connection:
Copy link
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.

@@ -232,12 +232,9 @@ def serve(self) -> None:
# 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
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
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
Copy link
Collaborator

JukkaL commented Dec 5, 2018

@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?

@ethanhs
Copy link
Collaborator Author

ethanhs commented Dec 6, 2018

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.

@ethanhs
Copy link
Collaborator Author

ethanhs commented Dec 11, 2018

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.

@ethanhs ethanhs closed this Dec 11, 2018
@ethanhs ethanhs 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