mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-12 12:53:31 +02:00
Merge bitcoin/bitcoin#31614: test: expect that files may disappear from /proc/PID/fd/
b2e9fdc00f5c40c241a37739f7b73b74c2181e39 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`](b2e9fdc00f
)
sipa:
utACK b2e9fdc00f5c40c241a37739f7b73b74c2181e39
achow101:
ACK b2e9fdc00f5c40c241a37739f7b73b74c2181e39
theuni:
utACK b2e9fdc00f5c40c241a37739f7b73b74c2181e39
hodlinator:
ACK b2e9fdc00f5c40c241a37739f7b73b74c2181e39
Tree-SHA512: 8eb05393e4de4307a70af446c3fc7e8f7dc3f08bf9d68d74d02b0e4e900cfd4865249f297be31f1fd7b05ffea45eb855c5cfcd75704167950c1deb4f17109f33
This commit is contained in:
commit
ff3171f96d
@ -41,9 +41,12 @@ def get_socket_inodes(pid):
|
||||
base = '/proc/%i/fd' % pid
|
||||
inodes = []
|
||||
for item in os.listdir(base):
|
||||
target = os.readlink(os.path.join(base, item))
|
||||
if target.startswith('socket:'):
|
||||
inodes.append(int(target[8:-1]))
|
||||
try:
|
||||
target = os.readlink(os.path.join(base, item))
|
||||
if target.startswith('socket:'):
|
||||
inodes.append(int(target[8:-1]))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return inodes
|
||||
|
||||
def _remove_empty(array):
|
||||
|
Loading…
x
Reference in New Issue
Block a user