pingnet: Fix ResourceWarning

master
Dustin 2017-04-06 10:51:14 -05:00
parent ef6d435d8d
commit 10e5548513
1 changed files with 5 additions and 4 deletions

View File

@ -64,9 +64,10 @@ class Pinger(threading.Thread):
break break
def ping(self, host): def ping(self, host):
with open(os.devnull, 'r+') as nul:
p = subprocess.Popen(['ping', '-c', '1', '-W', '1', host], p = subprocess.Popen(['ping', '-c', '1', '-W', '1', host],
stdin=open(os.devnull), stdin=nul,
stdout=open(os.devnull, 'w'), stdout=nul,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
p.wait() p.wait()
if p.returncode == 0: if p.returncode == 0: