Locally, I am seeing rare intermittent exceptions in the network thread:
0stderr:
1Exception in thread NetworkThread:
2Traceback (most recent call last):
3File "/python3.10/threading.py", line 1016, in _bootstrap_inner
4self.run()
5File "./test/functional/test_framework/p2p.py", line 744, in run
6self.network_event_loop.run_forever()
7File "/python3.10/asyncio/base_events.py", line 603, in run_forever
8self._run_once()
9File "/python3.10/asyncio/base_events.py", line 1871, in _run_once
10event_list = self._selector.select(timeout)
11AttributeError: 'NoneType' object has no attribute 'select'
I can reproduce this intermittently via while ./bld-cmake/test/functional/test_runner.py $(for i in {1..400}; do echo -n "tool_rpcauth "; done) -j 400 ; do true ; done
.
I suspect this is a race where the shutdown starts the close of the network thread while it is starting.
A different exception showing this race can be reproduced via:
0diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
1index 610aa4ccca..64561e157c 100755
2--- a/test/functional/test_framework/p2p.py
3+++ b/test/functional/test_framework/p2p.py
4@@ -741,6 +741,7 @@ class NetworkThread(threading.Thread):
5
6 def run(self):
7 """Start the network thread."""
8+ import time;time.sleep(.1)
9 self.network_event_loop.run_forever()
10
11 def close(self, *, timeout=10):
It is trivial to reproduce via any test (e.g. ./bld-cmake/test/functional/tool_rpcauth.py
) and shows a similar traceback to the one above:
0Exception in thread NetworkThread:
1Traceback (most recent call last):
2 File "/python3.10/threading.py", line 1016, in _bootstrap_inner
3 self.run()
4 File "./test/functional/test_framework/p2p.py", line 745, in run
5 self.network_event_loop.run_forever()
6 File "/python3.10/asyncio/base_events.py", line 591, in run_forever
7 self._check_closed()
8 File "/python3.10/asyncio/base_events.py", line 515, in _check_closed
9 raise RuntimeError('Event loop is closed')
10RuntimeError: Event loop is closed
So fix the second runtime error in hope of fixing the first one as well.