Skip to content

Add support for mypy daemon on Windows #5019

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

Closed
ilevkivskyi opened this issue May 10, 2018 · 15 comments
Closed

Add support for mypy daemon on Windows #5019

ilevkivskyi opened this issue May 10, 2018 · 15 comments

Comments

@ilevkivskyi
Copy link
Member

There is a major limitation for mypy daemon and fine-grained incremental mode: mypy daemon doesn't work on Windows, see http://mypy.readthedocs.io/en/latest/mypy_daemon.html#limitations

In particular, dmypy_server.daemonize uses some functionalities not available on Windows (such as os.fork). It would be great to remove this limitation (and update Appveyor to test the support).

@ethanhs It looks like you have most experience on Windows among all of us, would you like to take this task?

@emmatyping
Copy link
Member

@ilevkivskyi I have a few more things to follow up on for PEP 561, but after that I can take this.

@emmatyping emmatyping self-assigned this May 10, 2018
@emmatyping
Copy link
Member

emmatyping commented May 16, 2018

Mostly for myself, but also those who are interested:

After looking at the implementation a bit and talking with Steve Dower (who was very helpful!) I think the best plan is to use named pipes (which act esesentially like Unix sockets on Windows) for communication and a detached process (using creation flags of Popen). This should be enough to approximate the current UNIX API used by the mypy daemon. We will end up using _winapi.

@emmatyping
Copy link
Member

As an update, I have finally figured out the Windows API incantations needed to get a server/client setup working over named pipes, and can spawn a detached process which together essentially emulate much of the fork/Unix pipe aspects of the classic Unix daemon. I will start working on the actually mypy daemon now I know how I will implement it :)

@ilevkivskyi
Copy link
Member Author

@ethanhs Sorry for disturbing you, just wanted to check if there are any updates on this. This problem just appeared again in other context.

Thanks for helping with this!

@emmatyping
Copy link
Member

@ilevkivskyi no problem! I've been a bit side-tracked with some PEP 561 stuff, so nothing new to report sadly. I will get back to this soon hopefully.

@emmatyping
Copy link
Member

Unfortunately, I do not think I will have time to work on this any time soon (at least until December most likely). I am going to un-assign myself so someone else can pick this up if they are interested, but if not, I will come back to this in December.

@emmatyping emmatyping removed their assignment Sep 20, 2018
@JukkaL
Copy link
Collaborator

JukkaL commented Oct 24, 2018

@ethanhs Do you happen to have any prototype/work-in-progress code you can share? It's okay if it's not very polished.

@emmatyping
Copy link
Member

@JukkaL I have some experiments with named pipes and detached processes I could upload. Nothing really mypy specific, mostly experiments to understand the APIs and how a daemon would work.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 24, 2018

I have some experiments with named pipes and detached processes I could upload.

Those could be quite helpful, and I'd appreciate if you can share them! Our plan is to add Windows support in the next few weeks, as part of making mypy daemon a more fully supported feature.

@emmatyping
Copy link
Member

emmatyping commented Oct 24, 2018

@JukkaL That is good to know. If it is such high priority I would be happy to help how I can. I originally put this off because I felt other things were higher priority (with many things "high-priority" it sometimes can be hard to tell how to prioritize 😄 ).

Anyway, here is the experimental code I had: https://github.com/ethanhs/windows-daemon-python

It doesn't exactly work correctly, but it covers a rough sketch of how the named pipes code is supposed to be used. For the DETACHED_PROCESS flag, you basically need to just add creationflags=0x00000008 to your subprocess call (0x00000008 being the DETACHED_PROCESS flag).

@emmatyping
Copy link
Member

emmatyping commented Oct 26, 2018

Okay, well I got somewhat nerd-sniped (perhaps I self-sniped) :) I have a branch with some work I just did that daemonizes the server with a detached process, passing arguments via a temporary pickle'd file. I'm still working on getting named pipes to work for IPC, but hopefully I can get something working today or tomorrow.

The branch is available here: https://github.com/ethanhs/mypy/tree/windmypy

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 29, 2018

@ethanhs Thanks! It looks like you are most of the way there already.

@emmatyping
Copy link
Member

@JukkaL yes, if you want, I can probably get a prototype working this week.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 29, 2018

@ethanhs That would be great! But I can also finish it up if you are busy.

@emmatyping
Copy link
Member

@JukkaL I will have time to work on it this week. If I get stuck I will let you know.

emmatyping added a commit that referenced this issue Nov 27, 2018
This also adds an IPC module to abstract communication between the client and server for Unix and Windows.

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

No branches or pull requests

3 participants