-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for concurrent room initialization
- Loading branch information
1 parent
3a983e6
commit 5cec219
Showing
3 changed files
with
147 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
import sys | ||
|
||
if sys.version_info < (3, 10): | ||
from importlib_metadata import entry_points | ||
else: | ||
from importlib.metadata import entry_points | ||
|
||
from anyio import create_task_group, sleep | ||
from pycrdt_websocket import WebsocketProvider | ||
|
||
jupyter_ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")} | ||
|
||
|
||
async def test_room_concurrent_initialization( | ||
rtc_create_file, | ||
rtc_connect_doc_client, | ||
): | ||
file_format = "text" | ||
file_type = "file" | ||
file_path = "dummy.txt" | ||
await rtc_create_file(file_path) | ||
jupyter_ydoc = jupyter_ydocs[file_type]() | ||
|
||
async def connect(file_format, file_type, file_path, jupyter_ydoc): | ||
async with await rtc_connect_doc_client(file_format, file_type, file_path) as ws: | ||
async with WebsocketProvider(jupyter_ydoc.ydoc, ws): | ||
await sleep(0.1) | ||
|
||
async with create_task_group() as tg: | ||
tg.start_soon(connect, file_format, file_type, file_path, jupyter_ydoc) | ||
tg.start_soon(connect, file_format, file_type, file_path, jupyter_ydoc) |