Files
bitcoin/test/functional/test_framework
MarcoFalke fa050da980 test: Move event loop creation to network thread
This should fix https://github.com/bitcoin/bitcoin/issues/34367

I am not familiar with Windows sockets thread-safety, but creating the
event loop on the main thread, and running it in the network thread
could lead to a fast abort in Python on Windows (without any stderr):

```
77/276 - wallet_txn_clone.py failed, Duration: 1 s

stdout:
2025-12-10T08:04:27.500134Z TestFramework (INFO): PRNG seed is: 4018092284830106117

stderr:

Combine the logs and print the last 99999999 lines ...
============
Combined log for D:\a\_temp/test_runner_₿_🏃_20251210_075632/wallet_txn_clone_196:
============
 test  2025-12-10T08:04:27.500134Z TestFramework (INFO): PRNG seed is: 4018092284830106117
 test  2025-12-10T08:04:27.500433Z TestFramework (DEBUG): Setting up network thread
```

Also, I couldn't find any docs that require the loop must be created on
the thread that runs them:

* https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.new_event_loop
* https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_forever

However, the patch seems trivial to review, harmless, and easy to
revert, so it may be a good try to fix the intermittent Windows Python
crash.
2026-03-13 13:48:47 +01:00
..