pingnet: Fix ResourceWarning
parent
ef6d435d8d
commit
10e5548513
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue