Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multithreading flag #14

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Loading