Fix KeyError on batch requests whose state is freed before it is read (#36638)
This commit is contained in:
@@ -1688,13 +1688,22 @@ class TokenizerManager(TokenizerControlMixin, TokenizerManagerScoreMixin):
|
||||
|
||||
return None
|
||||
|
||||
async def _wait_one_response(
|
||||
def _wait_one_response(
|
||||
self,
|
||||
obj: Union[GenerateReqInput, EmbeddingReqInput],
|
||||
request: Optional[fastapi.Request] = None,
|
||||
):
|
||||
"""Wait for the response of one request."""
|
||||
# Batch dispatch builds every waiter before advancing any.
|
||||
# Both removers append the output after the del, so the ReqState stays valid.
|
||||
state = self.rid_to_state[obj.rid]
|
||||
return self._stream_one_response(obj=obj, state=state, request=request)
|
||||
|
||||
async def _stream_one_response(
|
||||
self,
|
||||
obj: Union[GenerateReqInput, EmbeddingReqInput],
|
||||
state: ReqState,
|
||||
request: Optional[fastapi.Request] = None,
|
||||
):
|
||||
# Not all request types have `stream` (e.g., EmbeddingReqInput). Default to non-streaming.
|
||||
is_stream = getattr(obj, "stream", False)
|
||||
while True:
|
||||
|
||||
Reference in New Issue
Block a user