@@ -305,10 +305,10 @@ def in_marimo_notebook() -> bool:
305305
306306def _mo_write_internal (cell_id , stream , value : object ) -> None :
307307 """Write to marimo cell given cell_id and stream."""
308- from marimo ._output import formatting
308+ from marimo ._messaging . cell_output import CellChannel
309309 from marimo ._messaging .ops import CellOp
310310 from marimo ._messaging .tracebacks import write_traceback
311- from marimo ._messaging . cell_output import CellChannel
311+ from marimo ._output import formatting
312312
313313 output = formatting .try_format (value )
314314 if output .traceback is not None :
@@ -325,9 +325,9 @@ def _mo_write_internal(cell_id, stream, value: object) -> None:
325325
326326def _mo_create_replace ():
327327 """Create mo.output.replace with current context pinned."""
328+ from marimo ._output import formatting
328329 from marimo ._runtime .context import get_context
329330 from marimo ._runtime .context .types import ContextNotInitializedError
330- from marimo ._output import formatting
331331
332332 try :
333333 ctx = get_context ()
@@ -525,9 +525,9 @@ def _extract(self, results):
525525 return results
526526 else :
527527 if results .is_zarr ():
528- from zarr .storage import ObjectStore
529528 import obstore
530529 import xarray as xr
530+ from zarr .storage import ObjectStore
531531
532532 assert self ._zarr_store is not None
533533
@@ -604,7 +604,9 @@ def cancel(self):
604604 self ._sampler .abort ()
605605
606606 def __del__ (self ):
607- if not self ._sampler .is_empty ():
607+ if not hasattr (self , "_sampler" ):
608+ return
609+ if not self ._sampler .is_empty (ignore_error = True ):
608610 self .cancel ()
609611
610612 def _repr_html_ (self ):
0 commit comments