import os
import time
- fd = os.open("{path}", os.O_RDWR | os.O_CREAT, 0644)
+ fd = os.open("{path}", os.O_RDWR | os.O_CREAT, 0o644)
try:
while True:
- os.write(fd, 'content')
+ os.write(fd, b'content')
time.sleep(1)
if not {loop}:
break
print("writing some data through which we expect to succeed")
bytes = 0
f = os.open("{file_path}", os.O_WRONLY | os.O_CREAT)
- bytes += os.write(f, 'a' * 512 * 1024)
+ bytes += os.write(f, b'a' * 512 * 1024)
os.fsync(f)
print("fsync'ed data successfully, will now attempt to fill fs")
full = False
for n in range(0, int({fill_mb} * 0.9)):
- bytes += os.write(f, 'x' * 1024 * 1024)
+ bytes += os.write(f, b'x' * 1024 * 1024)
print("wrote {{0}} bytes via buffered write, may repeat".format(bytes))
print("done writing {{0}} bytes".format(bytes))
print("starting buffered write")
try:
for n in range(0, int({fill_mb} * 0.2)):
- bytes += os.write(f, 'x' * 1024 * 1024)
+ bytes += os.write(f, b'x' * 1024 * 1024)
print("sleeping a bit as we've exceeded 90% of our expected full ratio")
time.sleep({full_wait})
except OSError:
print("writing some data through which we expect to succeed")
bytes = 0
f = os.open("{file_path}", os.O_WRONLY | os.O_CREAT)
- bytes += os.write(f, 'a' * 4096)
+ bytes += os.write(f, b'a' * 4096)
os.fsync(f)
print("fsync'ed data successfully, will now attempt to fill fs")
for n in range(0, int({fill_mb} * 1.1)):
try:
- bytes += os.write(f, 'x' * 1024 * 1024)
+ bytes += os.write(f, b'x' * 1024 * 1024)
print("wrote bytes via buffered write, moving on to fsync")
except OSError as e:
print("Unexpected error %s from write() instead of fsync()" % e)