Skip to content

Commit 886e708

Browse files
committed
rename some instances of "thr" to "process"
1 parent 7a36473 commit 886e708

34 files changed

+322
-322
lines changed

python/rsyscall/scripts/symsh.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ async def _mount(self, process: Process, path: Path) -> None:
8787
# We'll keep devfuse open *only* in the dedicated server process's private fd table, so that
8888
# other processes accessing the filesystem don't deadlock when we abort the FUSE server loop -
8989
# instead their syscalls will be aborted with ENOTCONN.
90-
self.thr = await process.fork()
91-
self.devfuse = self.thr.task.inherit_fd(devfuse)
90+
self.process = await process.fork()
91+
self.devfuse = self.process.task.inherit_fd(devfuse)
9292
await devfuse.close()
9393
# Respond to FUSE init message to sanity-check things are set up right.
94-
self.buf = await self.thr.malloc(FuseInList, FUSE_MIN_READ_BUFFER)
94+
self.buf = await self.process.malloc(FuseInList, FUSE_MIN_READ_BUFFER)
9595
[init] = await self.read()
9696
if not isinstance(init, FuseInitOp):
9797
raise Exception("oops, got non-init as first message", init)
@@ -115,7 +115,7 @@ async def read(self) -> FuseInList:
115115

116116
async def write(self, out: FuseOut) -> None:
117117
logger.debug("writing out FUSE response: %s", out)
118-
ptr = await self.thr.ptr(out)
118+
ptr = await self.process.ptr(out)
119119
written, unwritten = await self.devfuse.write(ptr)
120120
if unwritten.size() != 0:
121121
raise Exception("/dev/fuse is not supposed to ever do partial writes, but I got one somehow on", ptr)
@@ -125,11 +125,11 @@ async def __aenter__(self) -> FuseFS:
125125

126126
async def cleanup(self) -> None:
127127
# umount to kill the fuse loop; it's a bit lazy to save the parent process to do this, but we
128-
# can't do it in self.thr because that process spends all its time blocked in read.
128+
# can't do it in self.process because that process spends all its time blocked in read.
129129
await self.parent_process.task.umount(await self.parent_process.ptr(self.path))
130130
# and exit the process - but it might already be dead, so we might fail to exit it, just ignore that.
131131
try:
132-
await self.thr.exit(0)
132+
await self.process.exit(0)
133133
except SyscallError:
134134
pass
135135

python/rsyscall/stdlib/mktemp.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ def random_string(k: int=8) -> str:
1111
"Return a random string - useful for making files that don't conflict with others."
1212
return ''.join(random.choices(string.ascii_letters + string.digits, k=k))
1313

14-
async def update_symlink(thr: Process, path: WrittenPointer[Path],
14+
async def update_symlink(process: Process, path: WrittenPointer[Path],
1515
target: t.Union[str, os.PathLike]) -> WrittenPointer[Path]:
1616
"Atomically update this path to contain a symlink pointing at this target."
1717
tmpname = path.value.name + ".updating." + random_string(k=8)
18-
tmppath = await thr.ram.ptr(path.value.parent/tmpname)
19-
await thr.task.symlink(await thr.ram.ptr(target), tmppath)
20-
await thr.task.rename(tmppath, path)
18+
tmppath = await process.ram.ptr(path.value.parent/tmpname)
19+
await process.task.symlink(await process.ram.ptr(target), tmppath)
20+
await process.task.rename(tmppath, path)
2121
return path
2222

23-
async def mkdtemp(thr: Process, prefix: str="mkdtemp") -> 'TemporaryDirectory':
24-
"Make a temporary directory in thr.environ.tmpdir."
25-
parent = thr.environ.tmpdir
23+
async def mkdtemp(process: Process, prefix: str="mkdtemp") -> 'TemporaryDirectory':
24+
"Make a temporary directory in process.environ.tmpdir."
25+
parent = process.environ.tmpdir
2626
name = prefix+"."+random_string(k=8)
27-
await thr.task.mkdir(await thr.ram.ptr(parent/name), 0o700)
28-
return TemporaryDirectory(thr, parent, name)
27+
await process.task.mkdir(await process.ram.ptr(parent/name), 0o700)
28+
return TemporaryDirectory(process, parent, name)
2929

3030
class TemporaryDirectory(Path):
3131
"A temporary directory we've created and are responsible for cleaning up."
32-
def __init__(self, thr: Process, parent: Path, name: str) -> None:
32+
def __init__(self, process: Process, parent: Path, name: str) -> None:
3333
"Don't directly instantiate, use rsyscall.mktemp.mkdtemp to create this class."
34-
self.thr = thr
34+
self.process = process
3535
super().__init__(parent, name)
3636

3737
async def cleanup(self) -> None:
@@ -43,9 +43,9 @@ async def cleanup(self) -> None:
4343
4444
"""
4545
# TODO would be nice if not sharing the fs information gave us a cap to chdir
46-
cleanup = await self.thr.fork()
46+
cleanup = await self.process.fork()
4747
await cleanup.task.chdir(await cleanup.ram.ptr(self.parent))
48-
child = await cleanup.exec(self.thr.environ.sh.args(
48+
child = await cleanup.exec(self.process.environ.sh.args(
4949
'-c', f"chmod -R +w -- {self.name} && rm -rf -- {self.name}"))
5050
await child.check()
5151

python/rsyscall/tests/test_benchmark.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class TestBenchmark(TrioTestCase):
1515
async def test_bench(self):
1616
"Run a simple clone and exec case inside cProfile (without asserting the results)"
1717

18-
await self.thr.environ.as_arglist(self.thr.ram)
19-
cmd = (await self.thr.environ.which("echo")).args("-n")
18+
await self.process.environ.as_arglist(self.process.ram)
19+
cmd = (await self.process.environ.which("echo")).args("-n")
2020
pr = cProfile.Profile()
2121
warm_up_runs = 1
2222
real_runs = 1
23-
await rsys_run(self.thr, cmd, warm_up_runs)
23+
await rsys_run(self.process, cmd, warm_up_runs)
2424
pr.enable()
25-
await rsys_run(self.thr, cmd, real_runs)
25+
await rsys_run(self.process, cmd, real_runs)
2626
pr.disable()
2727
# pr.print_stats(sort='cumtime')
2828
# ps = pstats.Stats(pr).strip_dirs().sort_stats('cumulative')

python/rsyscall/tests/test_cat.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
class TestCat(TrioTestCase):
88
async def asyncSetUp(self) -> None:
9-
self.cat = await self.thr.environ.which("cat")
10-
self.pipe_in = await (await self.thr.task.pipe(await self.thr.ram.malloc(Pipe))).read()
11-
self.pipe_out = await (await self.thr.task.pipe(await self.thr.ram.malloc(Pipe))).read()
12-
process = await self.thr.fork()
9+
self.cat = await self.process.environ.which("cat")
10+
self.pipe_in = await (await self.process.task.pipe(await self.process.ram.malloc(Pipe))).read()
11+
self.pipe_out = await (await self.process.task.pipe(await self.process.ram.malloc(Pipe))).read()
12+
process = await self.process.fork()
1313
await process.task.inherit_fd(self.pipe_in.read).dup2(process.stdin)
1414
await process.task.inherit_fd(self.pipe_out.write).dup2(process.stdout)
1515
self.child = await process.exec(self.cat)
1616

1717
async def test_cat_pipe(self) -> None:
18-
in_data = await self.thr.ram.ptr(b"hello")
18+
in_data = await self.process.ram.ptr(b"hello")
1919
written, _ = await self.pipe_in.write.write(in_data)
2020
valid, _ = await self.pipe_out.read.read(written)
2121
self.assertEqual(in_data.value, await valid.read())
@@ -24,9 +24,9 @@ async def test_cat_pipe(self) -> None:
2424
await self.child.check()
2525

2626
async def test_cat_async(self) -> None:
27-
stdin = await self.thr.make_afd(self.pipe_in.write, set_nonblock=True)
28-
stdout = await self.thr.make_afd(self.pipe_out.read, set_nonblock=True)
29-
in_data = await self.thr.ram.ptr(b"hello")
27+
stdin = await self.process.make_afd(self.pipe_in.write, set_nonblock=True)
28+
stdout = await self.process.make_afd(self.pipe_out.read, set_nonblock=True)
29+
in_data = await self.process.ram.ptr(b"hello")
3030
written, _ = await stdin.write(in_data)
3131
valid, _ = await stdout.read(written)
3232
self.assertEqual(in_data.value, await valid.read())

python/rsyscall/tests/test_chroot.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
class TestChroot(TrioTestCase):
1010
async def asyncSetUp(self) -> None:
11-
self.tmpdir = await mkdtemp(self.thr)
12-
self.thr = await self.thr.clone(CLONE.NEWUSER|CLONE.NEWNS)
11+
self.tmpdir = await mkdtemp(self.process)
12+
self.process = await self.process.clone(CLONE.NEWUSER|CLONE.NEWNS)
1313

1414
async def asyncTearDown(self) -> None:
1515
await self.tmpdir.cleanup()
1616

1717
async def test_basic(self) -> None:
18-
await self.thr.mkdir(self.tmpdir/"proc")
19-
await self.thr.mount("/proc", self.tmpdir/"proc", "", MS.BIND, "")
20-
await self.thr.task.chroot(await self.thr.ptr(self.tmpdir))
21-
await self.thr.task.open(await self.thr.ptr("/proc/self"), O.RDONLY)
18+
await self.process.mkdir(self.tmpdir/"proc")
19+
await self.process.mount("/proc", self.tmpdir/"proc", "", MS.BIND, "")
20+
await self.process.task.chroot(await self.process.ptr(self.tmpdir))
21+
await self.process.task.open(await self.process.ptr("/proc/self"), O.RDONLY)

python/rsyscall/tests/test_clone.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class TestClone(TrioTestCase):
1313
async def asyncSetUp(self) -> None:
14-
self.child = await self.thr.clone(CLONE.FILES)
14+
self.child = await self.process.clone(CLONE.FILES)
1515

1616
async def test_exit(self) -> None:
1717
await self.child.exit(0)
@@ -35,7 +35,7 @@ async def test_two_children_exec(self) -> None:
3535
block forever.
3636
3737
"""
38-
thr2 = await self.thr.fork()
38+
thr2 = await self.process.fork()
3939
cmd = self.child.environ.sh.args('-c', 'true')
4040
child1 = await self.child.exec(cmd)
4141
child2 = await thr2.exec(cmd)
@@ -90,7 +90,7 @@ async def test_signal_queue(self) -> None:
9090

9191
class TestCloneUnshareFiles(TrioTestCase):
9292
async def asyncSetUp(self) -> None:
93-
self.child = await self.thr.fork()
93+
self.child = await self.process.fork()
9494

9595
async def asyncTearDown(self) -> None:
9696
await self.child.exit(0)

python/rsyscall/tests/test_epoller.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,39 @@ def get_activity_fd(self) -> t.Optional[FileDescriptor]:
3232

3333
class TestEpoller(TrioTestCase):
3434
async def test_local(self) -> None:
35-
await do_async_things(self, self.thr.epoller, self.thr)
35+
await do_async_things(self, self.process.epoller, self.process)
3636

3737
async def test_multi(self) -> None:
38-
await do_async_things(self, self.thr.epoller, self.thr, 0)
38+
await do_async_things(self, self.process.epoller, self.process, 0)
3939
async with trio.open_nursery() as nursery:
4040
for i in range(1, 6):
41-
nursery.start_soon(do_async_things, self, self.thr.epoller, self.thr, i)
41+
nursery.start_soon(do_async_things, self, self.process.epoller, self.process, i)
4242

4343
async def test_process_multi(self) -> None:
44-
process = await self.thr.fork()
44+
process = await self.process.fork()
4545
await do_async_things(self, process.epoller, process, 0)
4646
async with trio.open_nursery() as nursery:
4747
for i in range(1, 6):
4848
nursery.start_soon(do_async_things, self, process.epoller, process, i)
4949

5050
async def test_process_root_epoller(self) -> None:
51-
process = await self.thr.fork()
51+
process = await self.process.fork()
5252
epoller = await Epoller.make_root(process.ram, process.task)
5353
await do_async_things(self, epoller, process)
5454

5555
async def test_afd_with_handle(self):
56-
pipe = await self.thr.pipe()
57-
afd = await self.thr.make_afd(pipe.write, set_nonblock=True)
56+
pipe = await self.process.pipe()
57+
afd = await self.process.make_afd(pipe.write, set_nonblock=True)
5858
new_afd = afd.with_handle(pipe.write)
5959
await new_afd.write_all_bytes(b'foo')
6060

6161
async def test_delayed_eagain(self):
62-
pipe = await self.thr.pipe()
63-
process = await self.thr.fork()
62+
pipe = await self.process.pipe()
63+
process = await self.process.fork()
6464
async_pipe_rfd = await process.make_afd(process.inherit_fd(pipe.read), set_nonblock=True)
6565
# write in parent, read in child
6666
input_data = b'hello'
67-
buf_to_write: Pointer[bytes] = await self.thr.ptr(input_data)
67+
buf_to_write: Pointer[bytes] = await self.process.ptr(input_data)
6868
buf_to_write, _ = await pipe.write.write(buf_to_write)
6969
self.assertEqual(await async_pipe_rfd.read_some_bytes(), input_data)
7070
buf = await process.malloc(bytes, 4096)
@@ -89,9 +89,9 @@ async def race_eagain():
8989

9090
async def test_wrong_op_on_pipe(self):
9191
"Reading or writing to the wrong side of a pipe fails immediately with an error"
92-
pipe = await self.thr.pipe()
93-
async_pipe_wfd = await self.thr.make_afd(pipe.write, set_nonblock=True)
94-
async_pipe_rfd = await self.thr.make_afd(pipe.read, set_nonblock=True)
92+
pipe = await self.process.pipe()
93+
async_pipe_wfd = await self.process.make_afd(pipe.write, set_nonblock=True)
94+
async_pipe_rfd = await self.process.make_afd(pipe.read, set_nonblock=True)
9595
# we actually are defined to get EBADF in this case, which is
9696
# a bit of a worrying error, but whatever
9797
with self.assertRaises(OSError) as cm:

python/rsyscall/tests/test_eventfd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
class TestEventfd(TrioTestCase):
66
async def asyncSetUp(self) -> None:
7-
self.fd = await self.thr.task.eventfd(0)
7+
self.fd = await self.process.task.eventfd(0)
88

99
async def asyncTearDown(self) -> None:
1010
await self.fd.close()
1111

1212
async def test(self) -> None:
1313
inval = Int64(10)
14-
written, _ = await self.fd.write(await self.thr.ram.ptr(inval))
14+
written, _ = await self.fd.write(await self.process.ram.ptr(inval))
1515
read, _ = await self.fd.read(written)
1616
self.assertEqual(inval, await read.read())

python/rsyscall/tests/test_fd.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class TestFS(TrioTestCase):
77
async def test_fd_gc(self) -> None:
88
"Verify that file descriptors actually get GC'd."
99
gc.collect()
10-
await self.thr.task.run_fd_table_gc()
11-
devnull = await self.thr.ptr("/dev/null")
12-
first = int(await self.thr.task.open(devnull, O.RDONLY))
10+
await self.process.task.run_fd_table_gc()
11+
devnull = await self.process.ptr("/dev/null")
12+
first = int(await self.process.task.open(devnull, O.RDONLY))
1313
for _ in range(5):
14-
child = await self.thr.clone(CLONE.FILES)
14+
child = await self.process.clone(CLONE.FILES)
1515
for _ in range(50):
1616
await child.task.open(devnull, O.RDONLY)
1717
gc.collect()
18-
await self.thr.task.run_fd_table_gc()
19-
last = int(await self.thr.task.open(devnull, O.RDONLY))
18+
await self.process.task.run_fd_table_gc()
19+
last = int(await self.process.task.open(devnull, O.RDONLY))
2020
self.assertEqual(first, last)

0 commit comments

Comments
 (0)