Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jroesch committed Dec 23, 2023
1 parent 9c60f18 commit 58ccc23
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions serve/mlc_serve/engine/async_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@

ResultQueue = asyncio.Queue[RequestOutput]

import contextvars
import functools
from asyncio import get_running_loop

CANCELLATION_EXECUTOR = ThreadPoolExecutor(None)

async def to_thread_with_cancel_pool(func, /, *args, **kwargs):
"""Asynchronously run function *func* in a separate thread.
Any *args and **kwargs supplied for this function are directly passed
to *func*. Also, the current :class:`contextvars.Context` is propagated,
allowing context variables from the main thread to be accessed in the
separate thread.
Return a coroutine that can be awaited to get the eventual result of *func*.
"""
loop = get_running_loop()
ctx = contextvars.copy_context()
func_call = functools.partial(ctx.run, func, *args, **kwargs)
return await loop.run_in_executor(CANCELLATION_EXECUTOR, func_call)

class AsyncEngineConnector:
def __init__(self, engine: InferenceEngine, engine_wait_timeout=1):
self.engine = engine
Expand Down

0 comments on commit 58ccc23

Please sign in to comment.