-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add support for dmypy on Windows #5859
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
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
63aa4e2
Initial dmypy for Windows work
emmatyping abc64b7
Fixes related to dmypy server on Windows
emmatyping cf33bfa
Get dmypy start,stop,run,kill,check,restart working! :tada:
emmatyping 54859da
Only use _winapi on Windows
emmatyping f760e16
Guard _winapi import dmypy_server
emmatyping 966117c
Get dmypy status working on Windows
emmatyping 68ee937
Add support for timeout
emmatyping f6a42c3
Fix lint on Linux
emmatyping 168e177
Change a while 1 to a while True
emmatyping 3e0d12e
Minor refactoring
emmatyping 87e61c5
Move conditional imports to end of imports
emmatyping 1883c31
Minor fixes, corrections, simplifications
emmatyping 7932bb7
Merge branch 'master' of github.com:python/mypy into windmypy
emmatyping 8fb7203
Remove outdated docs
emmatyping 69d04dd
Respond to Guido's comments
emmatyping 968e07c
Lower timeout back down to 5s
emmatyping 037267a
Major refactoring into separate IPC module
emmatyping db202c2
Fix typing import for Python 3.5.1
emmatyping 55250a8
Correct out of date comments and remove unused imports
emmatyping f066484
Quote types so they don't need to be imported at runtime
emmatyping 54cba38
Minor code cleanup
emmatyping 072518b
Remove unused loop
emmatyping f033c54
Remove some more unused imports
emmatyping 768a2bf
Make pipe name and options file unique
emmatyping 32ef5c9
Merge branch 'master' into windmypy
msullivan 962072a
Move a conditional def out of IPCBase
msullivan 8d909c5
Remove dead code
emmatyping 7896a73
Merge branch 'windmypy' of github.com:ethanhs/mypy into windmypy
emmatyping eca5beb
Fix lint failure
emmatyping 941b1f2
Move to passing options via command instead of file
emmatyping 06459a8
Unify interface of daemonize
emmatyping 1feaf0e
Add comment about IPC behavior
emmatyping 34bd86a
Move process status checking and killing into dmypy_os
emmatyping c4d0bad
Add test for IPC
emmatyping ed4548d
Handle ERROR_PIPE_CONNECTED
emmatyping 681408f
Give the server more time to get set up in testipc?
emmatyping f484143
Fix unix daemonize typo (and slightly regeneralize)
msullivan 512c60e
Fix IPC tests
emmatyping 09b4913
Fix typecheck of ipc tests
emmatyping d2695ca
Reraise if exceptions occure and unify IPC initialization
emmatyping 76e0539
Merge branch master into ethanhs/windmypy
emmatyping 4956188
Get tests passing on Windows
emmatyping 4e0dcc1
Merge branch 'windmypy' of github.com:ethanhs/mypy into windmypy
emmatyping 842712e
Try an empty string/quotes instead of single quotes
emmatyping 5d9e149
Really fix daemon tests
emmatyping 959f89a
Remove busy wait and give better debug info
emmatyping 326758c
Temporary debug info
emmatyping d806282
Reuse NamedPipe for multiple connections
emmatyping 989ca72
Conditionally import Options in dmypy
emmatyping da719d6
Remove debug info
emmatyping c2d8d90
Merge upstream into windmypy
emmatyping a732a1e
Be more eager in removing status file
emmatyping dae10eb
Remove redundant parens
emmatyping 9de1b88
Use random bytes for NamedPipe name
emmatyping f3b8bb6
Document timeouts on Windows
emmatyping 0c43879
Add line in note
emmatyping File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
|
||
from typing import Any, Callable | ||
|
||
if sys.platform == 'win32': | ||
import ctypes | ||
from ctypes.wintypes import DWORD, HANDLE | ||
import subprocess | ||
|
||
PROCESS_QUERY_LIMITED_INFORMATION = ctypes.c_ulong(0x1000) | ||
|
||
kernel32 = ctypes.windll.kernel32 | ||
OpenProcess = kernel32.OpenProcess # type: Callable[[DWORD, int, int], HANDLE] | ||
GetExitCodeProcess = kernel32.GetExitCodeProcess # type: Callable[[HANDLE, Any], int] | ||
else: | ||
import os | ||
import signal | ||
|
||
|
||
def alive(pid: int) -> bool: | ||
"""Is the process alive?""" | ||
if sys.platform == 'win32': | ||
# why can't anything be easy... | ||
status = DWORD() | ||
handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, | ||
0, | ||
pid) | ||
GetExitCodeProcess(handle, ctypes.byref(status)) | ||
return status.value == 259 # STILL_ACTIVE | ||
else: | ||
try: | ||
os.kill(pid, 0) | ||
except OSError: | ||
return False | ||
return True | ||
|
||
|
||
def kill(pid: int) -> None: | ||
"""Kill the process.""" | ||
if sys.platform == 'win32': | ||
subprocess.check_output("taskkill /pid {pid} /f /t".format(pid=pid)) | ||
else: | ||
os.kill(pid, signal.SIGKILL) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.