Skip to content

Commit

Permalink
Use multithreading flag (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Frédéric Collonval <[email protected]>
  • Loading branch information
fcollonval and fcollonval authored Dec 13, 2024
1 parent 8ec1977 commit 32045b3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jupyter_nbmodel_client/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def output_hook(outputs: list[dict[str, t.Any]], message: dict[str, t.Any]) -> s
return set()




class KernelClient(t.Protocol):
"""Interface to be implemented by the kernel client."""

Expand Down Expand Up @@ -121,7 +119,9 @@ class NotebookModel(MutableSequence):
# FIXME add API to clear code cell; aka execution count and outputs

def __init__(self) -> None:
self._doc = YNotebook()
self._doc: YNotebook
# Initialize _doc
self._reset_y_model()

def __delitem__(self, index: int) -> NotebookNode:
raw_ycell = self._doc.ycells.pop(index)
Expand Down Expand Up @@ -312,4 +312,6 @@ def set_cell_source(self, index: int, source: str) -> None:

def _reset_y_model(self) -> None:
"""Reset the Y model."""
self._doc = YNotebook()
# Use allow_multithreading=True to ensure blocking document transactions
# https://jupyter-server.github.io/pycrdt/usage/#Transactions
self._doc = YNotebook(ydoc=pycrdt.Doc(allow_multithreading=True))

0 comments on commit 32045b3

Please sign in to comment.