Skip to content

Commit ff3171f

Browse files
committed
Merge bitcoin/bitcoin#31614: test: expect that files may disappear from /proc/PID/fd/
b2e9fdc test: expect that files may disappear from /proc/PID/fd/ (Vasil Dimov) Pull request description: `get_socket_inodes()` calls `os.listdir()` and then iterates on the results using `os.readlink()`. However a file may disappear from the directory after `os.listdir()` and before `os.readlink()` resulting in a `FileNotFoundError` exception. It is expected that this may happen for `bitcoind` which is running and could open or close files or sockets at any time. Thus ignore the `FileNotFoundError` exception. ACKs for top commit: arejula27: ACK [`b2e9fdc`](bitcoin/bitcoin@b2e9fdc) sipa: utACK b2e9fdc achow101: ACK b2e9fdc theuni: utACK b2e9fdc hodlinator: ACK b2e9fdc Tree-SHA512: 8eb05393e4de4307a70af446c3fc7e8f7dc3f08bf9d68d74d02b0e4e900cfd4865249f297be31f1fd7b05ffea45eb855c5cfcd75704167950c1deb4f17109f33
2 parents 1d813e4 + b2e9fdc commit ff3171f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/functional/test_framework/netutil.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ def get_socket_inodes(pid):
4141
base = '/proc/%i/fd' % pid
4242
inodes = []
4343
for item in os.listdir(base):
44-
target = os.readlink(os.path.join(base, item))
45-
if target.startswith('socket:'):
46-
inodes.append(int(target[8:-1]))
44+
try:
45+
target = os.readlink(os.path.join(base, item))
46+
if target.startswith('socket:'):
47+
inodes.append(int(target[8:-1]))
48+
except FileNotFoundError:
49+
pass
4750
return inodes
4851

4952
def _remove_empty(array):

0 commit comments

Comments
 (0)