sdk/python/lib/pulumi/runtime/invoke.py
def _sync_await(awaitable: Awaitable[Any]) -> Any:
    """
    _sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
    loop.
    """

    # Fetch the current event loop and ensure a future.
    loop = asyncio.get_event_loop()
    fut = asyncio.ensure_future(awaitable)

    # If the loop is not running, we can just use run_until_complete. Without this, we would need to duplicate a fair
    # amount of bookkeeping logic around loop startup and shutdown.
    if not loop.is_running():
        return loop.run_until_complete(fut)

    # If we are executing inside a task, pretend we've returned from its current callback--effectively yielding to
    # the event loop--by calling _leave_task.
    task = asyncio.Task.current_task(loop)
    if task is not None:
        _leave_task(loop, task)

    # Pump the event loop until the future is complete. This is the kernel of BaseEventLoop.run_forever, and may not
    # work with alternative event loop implementations.
    #
    # In order to make this reentrant with respect to _run_once, we keep track of the number of event handles on the
    # ready list and ensure that there are exactly that many handles on the list once we are finished.
    #
    # See https://github.com/python/cpython/blob/3.6/Lib/asyncio/base_events.py#L1428-L1452 for the details of the
    # _run_once kernel with which we need to cooperate.
    ntodo = len(loop._ready)
    while not fut.done() and not fut.cancelled():
        loop._run_once()
        if loop._stopping:
            break
    # If we drained the ready list past what a calling _run_once would have expected, fix things up by pushing
    # cancelled handles onto the list.
    while len(loop._ready) < ntodo:
        handle = asyncio.Handle(None, None, loop)
        handle._cancelled = True
        loop._ready.append(handle)

    # If we were executing inside a task, restore its context and continue on.
    if task is not None:
        _enter_task(loop, task)

    # Return the result of the future.
    return fut.result()

    _sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
    loop.
    
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
loop.
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop .
def _sync_await(awaitable: Awaitable[Any]) -> Any:
    loop = asyncio.get_event_loop()
    fut = asyncio.ensure_future(awaitable)
    if not loop.is_running():
        return loop.run_until_complete(fut)
    task = asyncio.Task.current_task(loop)
    if task is not None:
        _leave_task(loop, task)
     In order to make this reentrant with respect to _run_once, we keep track of the number of event handles on the
     ready list and ensure that there are exactly that many handles on the list once we are finished.
     See https://github.com/python/cpython/blob/3.6/Lib/asyncio/base_events.pyL1428-L1452 for the details of the
     _run_once kernel with which we need to cooperate.
    ntodo = len(loop._ready)
    while not fut.done() and not fut.cancelled():
        loop._run_once()
        if loop._stopping:
            break
     If we drained the ready list past what a calling _run_once would have expected, fix things up by pushing
     cancelled handles onto the list.
    while len(loop._ready) < ntodo:
        handle = asyncio.Handle(None, None, loop)
        handle._cancelled = True
        loop._ready.append(handle)
     If we were executing inside a task, restore its context and continue on.
    if task is not None:
        _enter_task(loop, task)
     Return the result of the future.
    return fut.result()
def _sync_await ( awaitable : Awaitable [ Any ] ) -> Any : loop = asyncio . get_event_loop ( ) fut = asyncio . ensure_future ( awaitable ) if not loop . is_running ( ) : return loop . run_until_complete ( fut ) task = asyncio . Task . current_task ( loop ) if task is not None : _leave_task ( loop , task ) ntodo = len ( loop . _ready ) while not fut . done ( ) and not fut . cancelled ( ) : loop . _run_once ( ) if loop . _stopping : break while len ( loop . _ready ) < ntodo : handle = asyncio . Handle ( None , None , loop ) handle . _cancelled = True loop . _ready . append ( handle ) if task is not None : _enter_task ( loop , task ) return fut . result ( )
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
loop.
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event loop .
"""
    _sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
    loop.
    """ # Fetch the current event loop and ensure a future. # If the loop is not running, we can just use run_until_complete. Without this, we would need to duplicate a fair # amount of bookkeeping logic around loop startup and shutdown. # If we are executing inside a task, pretend we've returned from its current callback--effectively yielding to # the event loop--by calling _leave_task. # Pump the event loop until the future is complete. This is the kernel of BaseEventLoop.run_forever, and may not # work with alternative event loop implementations. # # In order to make this reentrant with respect to _run_once, we keep track of the number of event handles on the # ready list and ensure that there are exactly that many handles on the list once we are finished. # # See https://github.com/python/cpython/blob/3.6/Lib/asyncio/base_events.py#L1428-L1452 for the details of the # _run_once kernel with which we need to cooperate. # If we drained the ready list past what a calling _run_once would have expected, fix things up by pushing # cancelled handles onto the list. # If we were executing inside a task, restore its context and continue on. # Return the result of the future.
awaitable
Awaitable[Any]