Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: make recv robust to EAGAIN, EDEADLK (#1822)

Akshay Agrawal5b62b28ffd92
diff --git a/marimo/_utils/distributor.py b/marimo/_utils/distributor.py
index 9241a4e892..7f77ba689e 100644
--- a/marimo/_utils/distributor.py
+++ b/marimo/_utils/distributor.py
@@ -2,6 +2,7 @@
from __future__ import annotations
import asyncio
+import time
from typing import TYPE_CHECKING, Callable, Generic, TypeVar
from marimo import _loggers
@@ -49,9 +50,17 @@ class Distributor(Generic[T]):
def _on_change(self) -> None:
"""Distribute the response to all consumers."""
+ retry_sleep_seconds = 0.001
while self.input_connection.poll():
try:
response = self.input_connection.recv()
+ except BlockingIOError as e:
+ # recv() sporadically fails with EAGAIN, EDEADLK ...
+ LOGGER.warning(
+ "BlockingIOError in distributor receive: %s", str(e)
+ )
+ time.sleep(retry_sleep_seconds)
+ continue
except (EOFError, StopIteration):
break
for consumer in self.consumers: