Skip to content

Commit 0c25fa9

Browse files
committed
extract method
1 parent 58e1eec commit 0c25fa9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/a2a/server/routes/jsonrpc_dispatcher.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,12 @@ async def _process_streaming_request(
398398
An `AsyncGenerator` object to stream results to the client.
399399
"""
400400
stream: AsyncGenerator | None = None
401-
if context.state.get('method') == 'SendStreamingMessage':
401+
method = context.state.get('method')
402+
if method == 'SendStreamingMessage':
402403
stream = self.request_handler.on_message_send_stream(
403404
request_obj, context
404405
)
405-
elif context.state.get('method') == 'SubscribeToTask':
406+
elif method == 'SubscribeToTask':
406407
stream = self.request_handler.on_subscribe_to_task(
407408
request_obj, context
408409
)
@@ -549,7 +550,8 @@ async def _process_non_streaming_request( # noqa: PLR0911
549550
Returns:
550551
A dict containing the result or error.
551552
"""
552-
match context.state.get('method'):
553+
method = context.state.get('method')
554+
match method:
553555
case 'SendMessage':
554556
return await self._handle_send_message(request_obj, context)
555557
case 'CancelTask':
@@ -580,7 +582,6 @@ async def _process_non_streaming_request( # noqa: PLR0911
580582
request_obj, context
581583
)
582584
case _:
583-
method = context.state.get('method')
584585
logger.error('Unhandled method: %s', method)
585586
raise UnsupportedOperationError(
586587
message=f'Method {method} is not supported.'

0 commit comments

Comments
 (0)