Skip to content

Commit 1fee4ae

Browse files
Knarr-Forseticlaude
andcommitted
fix: set default executor to node's 32-thread pool
asyncio.to_thread and run_in_executor(None) use the default executor (5-8 threads). At 50+ nodes, concurrent thrall/RPC/sidecar calls exhaust it — urllib's internal DNS/connection calls queue behind them, making cockpit unresponsive. Share the node's existing 32+ thread pool. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 60e2d3b commit 1fee4ae

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/knarr/dht/node.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,9 @@ def _check_credit_restored(self, peer_public_key: str, old_balance: float, new_b
16111611
async def start(self):
16121612
"""Starts the server and background tasks."""
16131613
self._main_loop = asyncio.get_running_loop() # TEST-02: capture running loop (not deprecated get_event_loop)
1614+
# Share node's 32+ thread pool as default executor — prevents asyncio.to_thread
1615+
# and run_in_executor(None) from starving on the default 5-8 thread pool at scale.
1616+
self._main_loop.set_default_executor(self._handler_pool)
16141617
self.server = await asyncio.start_server(
16151618
self._handle_connection, self._bind_host, self.node_info.port
16161619
)

0 commit comments

Comments
 (0)