Skip to content

Commit 8ab6a20

Browse files
icankeepzhouwenhua02
andauthored
Compatible with asynchronous contentsmanager (#955)
* Compatible with asynchronous contentsmanager * lint the python code with black Co-authored-by: zhouwenhua02 <[email protected]>
1 parent 25955fe commit 8ab6a20

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

jupyterlab_git/git.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import tornado
1515
import tornado.locks
1616
from nbdime import diff_notebooks
17+
from jupyter_server.utils import ensure_async
1718

1819
from .log import get_logger
1920

@@ -1186,13 +1187,15 @@ async def show(self, filename, ref, path):
11861187
)
11871188
)
11881189

1189-
def get_content(self, contents_manager, filename, path):
1190+
async def get_content(self, contents_manager, filename, path):
11901191
"""
11911192
Get the file content of filename.
11921193
"""
11931194
relative_repo = os.path.relpath(path, contents_manager.root_dir)
11941195
try:
1195-
model = contents_manager.get(path=os.path.join(relative_repo, filename))
1196+
model = await ensure_async(
1197+
contents_manager.get(path=os.path.join(relative_repo, filename))
1198+
)
11961199
except tornado.web.HTTPError as error:
11971200
# Handle versioned file being deleted case
11981201
if error.status_code == 404 and error.log_message.startswith(
@@ -1210,7 +1213,7 @@ async def get_content_at_reference(
12101213
"""
12111214
if "special" in reference:
12121215
if reference["special"] == "WORKING":
1213-
content = self.get_content(contents_manager, filename, path)
1216+
content = await self.get_content(contents_manager, filename, path)
12141217
elif reference["special"] == "INDEX":
12151218
is_binary = await self._is_binary(filename, "INDEX", path)
12161219
if is_binary:

0 commit comments

Comments
 (0)