Skip to content

Commit

Permalink
Create WRITE_LOCK on first use
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 24, 2024
1 parent 8dea3cc commit e278a9a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions panel/io/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@
ModelChangedEvent
)
GC_DEBOUNCE = 5
WRITE_LOCK = asyncio.Lock()
_WRITE_LOCK = None

def WRITE_LOCK():
global WRITE_LOCK
if WRITE_LOCK is None:
WRITE_LOCK = asyncio.Lock()
return WRITE_LOCK

_panel_last_cleanup = None
_write_tasks = []
Expand Down Expand Up @@ -137,7 +143,7 @@ async def _run_write_futures(futures):
Ensure that all write_message calls are awaited and handled.
"""
from tornado.websocket import WebSocketClosedError
async with WRITE_LOCK:
async with WRITE_LOCK():
for future in futures:
try:
await future
Expand Down

0 comments on commit e278a9a

Please sign in to comment.