pingnet: Fix ResourceWarning
This commit is contained in:
@@ -64,10 +64,11 @@ class Pinger(threading.Thread):
|
||||
break
|
||||
|
||||
def ping(self, host):
|
||||
p = subprocess.Popen(['ping', '-c', '1', '-W', '1', host],
|
||||
stdin=open(os.devnull),
|
||||
stdout=open(os.devnull, 'w'),
|
||||
stderr=subprocess.STDOUT)
|
||||
with open(os.devnull, 'r+') as nul:
|
||||
p = subprocess.Popen(['ping', '-c', '1', '-W', '1', host],
|
||||
stdin=nul,
|
||||
stdout=nul,
|
||||
stderr=subprocess.STDOUT)
|
||||
p.wait()
|
||||
if p.returncode == 0:
|
||||
if not self.quiet:
|
||||
|
||||
Reference in New Issue
Block a user