MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / run_asyncio_coroutine

Function run_asyncio_coroutine

pywebio/session/__init__.py:425–444  ·  view source on GitHub ↗

If the thread running sessions are not the same as the thread running the asyncio event loop, you need to wrap ``run_asyncio_coroutine()`` to run the coroutine in asyncio. Can only be used in :ref:`coroutine-based session `. :param coro_obj: Coroutine obje

(coro_obj)

Source from the content-addressed store, hash-verified

423
424@check_session_impl(CoroutineBasedSession)
425async def run_asyncio_coroutine(coro_obj):
426 """
427 If the thread running sessions are not the same as the thread running the asyncio event loop,
428 you need to wrap ``run_asyncio_coroutine()`` to run the coroutine in asyncio.
429
430 Can only be used in :ref:`coroutine-based session <coroutine_based_session>`.
431
432 :param coro_obj: Coroutine object in `asyncio`
433
434 Example::
435
436 async def app():
437 put_text('hello')
438 await run_asyncio_coroutine(asyncio.sleep(1))
439 put_text('world')
440
441 pywebio.platform.flask.start_server(app)
442
443 """
444 return await get_current_session().run_asyncio_coroutine(coro_obj)
445
446
447@check_session_impl(ThreadBasedSession)

Callers 1

backgroundFunction · 0.85

Calls 2

get_current_sessionFunction · 0.85
run_asyncio_coroutineMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…