test: Use asyncio.SelectorEventLoop() over deprecated asyncio.WindowsSelectorEventLoopPolicy()
What changed, and why it matters
This is a tiny test-only code cleanup. It swaps one way of choosing an older-style event loop on Windows for another equivalent way, because the old approach is being removed in newer Python versions. It does not change Bitcoin Core's production network code, consensus rules, wallet handling, or any user-facing behavior. There is no security issue here.
No security action needed. Treat as routine maintenance/cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/functional/test_framework/p2p.py’s NetworkThread setup. Previously, on Windows it installed asyncio.WindowsSelectorEventLoopPolicy() globally and then called asyncio.new_event_loop(). The patch instead directly instantiates asyncio.SelectorEventLoop() on Windows and asyncio.new_event_loop() elsewhere. SelectorEventLoop is the same underlying loop type that the deprecated policy produced; this change merely avoids a deprecated/removed API. The change is confined to the functional test framework and has no effect on node runtime code.
Changed components
test/functional/test_framework/p2p.pyInspect captured patch +1 / −3
diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py
index 7a7cce61..bd8a1da7 100755
--- a/test/functional/test_framework/p2p.py
+++ b/test/functional/test_framework/p2p.py
@@ -740,9 +740,7 @@ class NetworkThread(threading.Thread):
NetworkThread.listeners = {}
NetworkThread.protos = {}
- if platform.system() == 'Windows':
- asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
- NetworkThread.network_event_loop = asyncio.new_event_loop()
+ NetworkThread.network_event_loop = asyncio.SelectorEventLoop() if platform.system() == "Windows" else asyncio.new_event_loop()
def run(self):
"""Start the network thread."""
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.