Skip to content
Open
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
24 changes: 24 additions & 0 deletions src/genie_python/matplotlib_backend/ibex_websocket_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,30 @@ def pyplot_show(cls, *args: Any, **kwargs: Any) -> None:
class _FigureCanvas(backend_webagg.FigureCanvasWebAgg):
manager_class = _FigureManager

def draw(self) -> None:
"""
Draw the figure.

This method takes the IBEX_BACKEND_LOCK, to avoid multiple threads
attempting to draw concurrently. This can happen if a draw triggered
from Python code happens at the same time as one triggered from
an incoming websocket request.
"""
with IBEX_BACKEND_LOCK:
super().draw()

def print_figure(self, *args: Any, **kwargs: Any) -> Any:
"""
Print the figure.

This method takes the IBEX_BACKEND_LOCK, to avoid multiple threads
attempting to draw concurrently. This can happen if a draw triggered
from Python code happens at the same time as one triggered from
an incoming websocket request.
"""
with IBEX_BACKEND_LOCK:
return super().print_figure(*args, **kwargs)

def set_image_mode(self, mode: str) -> None:
"""
Always send full images to ibex.
Expand Down
Loading