If you need the value in Python>=3.3, here's a simple method (assuming you can run call out to dd
):
from subprocess import Popen, PIPE, TimeoutExpired
p = Popen(["dd", "if=/dev/zero", "bs=1"], stdin=PIPE, stdout=PIPE)
try:
p.wait(timeout=1)
except TimeoutExpired:
p.kill()
print(len(p.stdout.read()))