How to use 'ping python' in Python

Every line of 'ping python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
7def ping(host, count=1, timeout=1):
8 cmd = [
9 'ping',
10 '-c',
11 str(count),
12 '-w',
13 str(timeout),
14 host,
15 ]
16
17 sub = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
18 sub.communicate()
19 ret = sub.wait() == 0
20 return ret
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets