MCPcopy Create free account
hub / github.com/ceph/ceph / write_background

Method write_background

qa/tasks/cephfs/mount.py:1225–1263  ·  view source on GitHub ↗

Open a file for writing, complete as soon as you can :param basename: :return:

(self, basename="background_file", loop=False)

Source from the content-addressed store, hash-verified

1223 ])
1224
1225 def write_background(self, basename="background_file", loop=False):
1226 """
1227 Open a file for writing, complete as soon as you can
1228 :param basename:
1229 :return:
1230 """
1231 assert(self.is_mounted())
1232
1233 path = os.path.join(self.hostfs_mntpt, basename)
1234
1235 pyscript = dedent("""
1236 import fcntl
1237 import os
1238 import sys
1239 import time
1240
1241 fcntl.fcntl(sys.stdin, fcntl.F_SETFL, fcntl.fcntl(sys.stdin, fcntl.F_GETFL) | os.O_NONBLOCK)
1242
1243 fd = os.open("{path}", os.O_RDWR | os.O_CREAT, 0o644)
1244 try:
1245 while True:
1246 print("write_background: writing", file=sys.stderr)
1247 os.write(fd, b'content')
1248 if not {loop}:
1249 break
1250 try:
1251 if os.read(0, 4096) == b"":
1252 break
1253 except BlockingIOError:
1254 pass
1255 time.sleep(2)
1256 except IOError as e:
1257 pass
1258 os.close(fd)
1259 """).format(path=path, loop=str(loop))
1260
1261 rproc = self._run_python(pyscript)
1262 self.background_procs.append(rproc)
1263 return rproc
1264
1265 def write_n_mb(self, filename, n_mb, seek=0, wait=True):
1266 """

Callers 7

test_network_deathMethod · 0.80
_test_stale_capsMethod · 0.80
test_evicted_capsMethod · 0.80
test_clientsMethod · 0.80
test_mds_readonlyMethod · 0.80

Calls 5

is_mountedMethod · 0.95
_run_pythonMethod · 0.95
joinMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45

Tested by 7

test_network_deathMethod · 0.64
_test_stale_capsMethod · 0.64
test_evicted_capsMethod · 0.64
test_clientsMethod · 0.64
test_mds_readonlyMethod · 0.64