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

Removed message 'No Instance(s) Available.' in Windows when starting … #2294

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion luigi/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def getpcmd(pid):
"""
if os.name == "nt":
# Use wmic command instead of ps on Windows.
cmd = 'wmic path win32_process where ProcessID=%s get Commandline' % (pid, )
cmd = 'wmic path win32_process where ProcessID=%s get Commandline 2> nul' % (pid, )
with os.popen(cmd, 'r') as p:
lines = [line for line in p.readlines() if line.strip("\r\n ") != ""]
if lines:
Expand Down
13 changes: 10 additions & 3 deletions test/lock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@
class TestCmd(unittest.TestCase):

def test_getpcmd(self):
p = subprocess.Popen(["sleep", "1"])
if os.name == 'nt':
command = ["ping", "1.1.1.1", "-w", "1000"]
else:
command = ["sleep", "1"]

external_process = subprocess.Popen(command)
result = luigi.lock.getpcmd(external_process.pid)

self.assertTrue(
luigi.lock.getpcmd(p.pid) in ["sleep 1", '[sleep]']
result.strip() in ["sleep 1", '[sleep]', 'ping 1.1.1.1 -w 1000']
)
p.kill()
external_process.kill()


class LockTest(unittest.TestCase):
Expand Down