File tree Expand file tree Collapse file tree 1 file changed +1
-18
lines changed Expand file tree Collapse file tree 1 file changed +1
-18
lines changed Original file line number Diff line number Diff line change 3
3
# Distributed under the terms of the Modified BSD License.
4
4
import errno
5
5
import importlib .util
6
- import inspect
7
6
import os
8
7
import socket
9
8
import sys
14
13
from urllib .request import pathname2url # noqa: F401
15
14
16
15
from _frozen_importlib_external import _NamespacePath
16
+ from jupyter_core .utils import ensure_async # noqa: F401
17
17
from packaging .version import Version
18
18
from tornado .httpclient import AsyncHTTPClient , HTTPClient , HTTPRequest
19
19
from tornado .netutil import Resolver
@@ -173,23 +173,6 @@ def _check_pid_posix(pid):
173
173
check_pid = _check_pid_posix
174
174
175
175
176
- async def ensure_async (obj ):
177
- """Convert a non-awaitable object to a coroutine if needed,
178
- and await it if it was not already awaited.
179
- """
180
- if inspect .isawaitable (obj ):
181
- try :
182
- result = await obj
183
- except RuntimeError as e :
184
- if str (e ) == "cannot reuse already awaited coroutine" :
185
- # obj is already the coroutine's result
186
- return obj
187
- raise
188
- return result
189
- # obj doesn't need to be awaited
190
- return obj
191
-
192
-
193
176
async def run_sync_in_loop (maybe_async ):
194
177
"""**DEPRECATED**: Use ``ensure_async`` instead."""
195
178
warnings .warn (
You can’t perform that action at this time.
0 commit comments