Skip to content

Commit

Permalink
Removed message 'No Instance(s) Available.' in Windows when starting … (
Browse files Browse the repository at this point in the history
  • Loading branch information
hirolau authored and Tarrasch committed Apr 8, 2018
1 parent 65dc89c commit 0d87424
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 0d87424

Please sign in to comment.