13c14eac076c81227a96e24f749392f5b75aa2ce,python/ray/experimental/async_api.py,,init,#,23

Before Change


    assert ray.is_initialized(), "Please call ray.init before async_api.init"

    // Noop when handler is set.
    if handler is not None:
        return

    loop = asyncio.get_event_loop()
    if loop.is_running():
        if loop._thread_id != threading.get_ident():
            // If the loop is runing outside current thread, we actually need
            // to do this to make sure the context is initialized.
            asyncio.run_coroutine_threadsafe(_async_init(), loop=loop)
        else:
            async_init_done = asyncio.get_event_loop().create_task(
                _async_init())
            // Block until the async init finishes.
            async_init_done.done()
    else:
        asyncio.get_event_loop().run_until_complete(_async_init())

After Change


    assert ray.is_initialized(), "Please call ray.init before async_api.init"

    global handler
    if handler is None:
        worker = ray.worker.global_worker
        loop = asyncio.get_event_loop()
        handler = PlasmaEventHandler(loop, worker)
        worker.core_worker.set_plasma_added_callback(handler)
        logger.debug("AsyncPlasma Connection Created!")


def as_future(object_id):
    Turn an object_id into a Future object.

    Args:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: ray-project/ray
Commit Name: 13c14eac076c81227a96e24f749392f5b75aa2ce
Time: 2020-04-25
Author: xmo@berkeley.edu
File Name: python/ray/experimental/async_api.py
Class Name:
Method Name: init


Project Name: streamlit/streamlit
Commit Name: c4d653ee7275f364b82d539bc58a9793248374eb
Time: 2019-06-05
Author: tconkling@gmail.com
File Name: lib/streamlit/ScriptRunner.py
Class Name: ScriptRunner
Method Name: maybe_handle_execution_control_request


Project Name: streamlit/streamlit
Commit Name: e0e9d7350826c7d968e48181cea38bde23942c30
Time: 2019-06-19
Author: tconkling@gmail.com
File Name: lib/streamlit/Server.py
Class Name: Server
Method Name: _add_browser_connection