aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-04 02:36:41 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-04 02:36:41 +0200
commit41282b997e016da0773276a935434dd03631e1f3 (patch)
treed05ac18544987a9c66ac33c12f05d956d895b96c /packages/meshbay-node/src/meshbay_node
parentc2620a5b269db75fcadb772e3ae5250886e8814c (diff)
downloadmeshbay-41282b997e016da0773276a935434dd03631e1f3.tar.gz
fix(node): MESHBAY_NODE_EVENT_LOOP=proactor to opt out of the selector loop
Whether aiortc actually hangs on the ProactorEventLoop for a live peer (as opposed to the same-process loopback the tests use) is still open. This lets a Windows node keep the default loop for that comparison — and, if Proactor turns out fine, keep subprocess ffmpeg working without a code change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node')
-rw-r--r--packages/meshbay-node/src/meshbay_node/platform.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/platform.py b/packages/meshbay-node/src/meshbay_node/platform.py
index 80aa6ae..2eab9e1 100644
--- a/packages/meshbay-node/src/meshbay_node/platform.py
+++ b/packages/meshbay-node/src/meshbay_node/platform.py
@@ -29,17 +29,23 @@ def force_utf8_stdio() -> None:
def use_compatible_event_loop() -> None:
"""
- aiortc's ICE stack (aioice) does not run on Windows' default
- ProactorEventLoop — a DataChannel handshake never completes and the
- connection hangs. Select the SelectorEventLoop before the loop is created.
+ On Windows, select the SelectorEventLoop: aiortc's ICE stack does not
+ complete a loopback DataChannel handshake on the default ProactorEventLoop.
Cost: SelectorEventLoop cannot spawn subprocesses on Windows, so ffmpeg
streaming (asyncio.create_subprocess_exec in webrtc_server.py) does not work
under it. The video path needs a thread-based runner on Windows — tracked
for the port. No effect off Windows.
+
+ Whether the hang is real for a live peer (vs. the same-process loopback in
+ the tests) is still being established: set MESHBAY_NODE_EVENT_LOOP=proactor
+ to keep the default loop and check.
"""
- if sys.platform == "win32":
- asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+ if sys.platform != "win32":
+ return
+ if os.environ.get("MESHBAY_NODE_EVENT_LOOP", "").lower() == "proactor":
+ return
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
# ── Directories ──────────────────────────────────────────────────────────────