File tree Expand file tree Collapse file tree 1 file changed +1
-17
lines changed Expand file tree Collapse file tree 1 file changed +1
-17
lines changed Original file line number Diff line number Diff line change 14
14
from urllib .request import pathname2url # noqa: F401
15
15
16
16
from _frozen_importlib_external import _NamespacePath
17
+ from jupyter_core .utils import ensure_async # noqa: F401
17
18
from packaging .version import Version
18
19
from tornado .httpclient import AsyncHTTPClient , HTTPClient , HTTPRequest
19
20
from tornado .netutil import Resolver
@@ -173,23 +174,6 @@ def _check_pid_posix(pid):
173
174
check_pid = _check_pid_posix
174
175
175
176
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
177
async def run_sync_in_loop (maybe_async ):
194
178
"""**DEPRECATED**: Use ``ensure_async`` instead."""
195
179
warnings .warn (
You can’t perform that action at this time.
0 commit comments