@@ -103,21 +103,27 @@ async def main() -> None:
103103
104104 client = client_factory .create (card = cards )
105105
106- if isinstance (client , MulticastClient ) and args .broadcast :
107- print (f"> { args .text } (broadcast live to { agent_names } )" )
108- await send_live_message_broadcast (client , args .text )
109- elif isinstance (client , MulticastClient ):
110- print (f"> { args .text } (multicast to { agent_names } )" )
111- await send_message_multicast (client , args .text )
112- elif args .live :
113- logger .info ("A2AClient initialized." )
114- print (f"> { args .text } (live)" )
115- await send_live_message (client , args .text )
116- else :
117- logger .info ("A2AClient initialized." )
118- response_text = await send_message (client , args .text )
119- print (f"> { args .text } " )
120- print (response_text )
106+ try :
107+ if isinstance (client , MulticastClient ) and args .broadcast :
108+ print (f"> { args .text } (broadcast live to { agent_names } )" )
109+ await send_live_message_broadcast (client , args .text )
110+ elif isinstance (client , MulticastClient ):
111+ print (f"> { args .text } (multicast to { agent_names } )" )
112+ await send_message_multicast (client , args .text )
113+ elif args .live :
114+ logger .info ("A2AClient initialized." )
115+ print (f"> { args .text } (live)" )
116+ await send_live_message (client , args .text )
117+ else :
118+ logger .info ("A2AClient initialized." )
119+ response_text = await send_message (client , args .text )
120+ print (f"> { args .text } " )
121+ print (response_text )
122+ except KeyboardInterrupt :
123+ pass
124+ finally :
125+ await client .close ()
126+ await httpx_client .aclose ()
121127
122128
123129def parse_arguments () -> argparse .Namespace :
0 commit comments