-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unreachable fsync call in SysCommandWorker.write #2773
Comments
That's because |
Hmm, mypy also flags that line as unreachable:
I tried this sample code to try to understand the semantics better: import os
import pty
def write():
return os.write(fd, b"foo")
raise AssertionError
os.fsync(fd)
pid, fd = pty.fork()
write() The code doesn't seem to trigger the I was thinking the archinstall code needed to be updated like the following, but I might be misunderstanding the existing command worker code: if self.child_fd:
bytes_written = os.write(self.child_fd, data + (b'\n' if line_ending else b''))
os.fsync(self.child_fd)
return bytes_written |
That example has no check if the code is executed in the parent or forked child. Both threads will call import pty
import random
pid, fd = pty.fork()
with open(f"/tmp/pid_{random.randint(0, 2000)}", "w") as fh:
fh.write(f"pid: {pid}, fd: {fd}") Both threads will execute, but with different values :) |
Thanks, the forking part makes sense :). I think the main item of confusion for me is how the archinstall/archinstall/lib/general.py Lines 217 to 219 in 7437668
My understanding is that the return would stop further execution regardless of whether the code is executed by the child or parent process. We can suppress the pylint and mypy warnings for line 219, but I would want to make sure it's a true false positive. Thanks! |
Ah yeah that return never happens, sorry about that one hehe. |
Description
pylint --enable=unreachable .
picks up the following unreachablefsync
call:archinstall/archinstall/lib/general.py
Lines 217 to 219 in 7437668
Warning
The text was updated successfully, but these errors were encountered: