66from typing import Any , AsyncGenerator , Callable , Coroutine , Iterator , Optional , Union
77
88from ..protocols import Broker as BrokerProtocol
9+ from ..service .asyncio_tasks import named_wait
910
1011logger = logging .getLogger (__name__ )
1112
@@ -77,6 +78,9 @@ async def _add_client(self, reader: asyncio.StreamReader, writer: asyncio.Stream
7778 client = Client (self .client_ct , reader , writer )
7879 self .clients [self .client_ct ] = client
7980 self .client_ct += 1
81+ current_task = asyncio .current_task ()
82+ if current_task is not None :
83+ current_task .set_name (f'socket_client_task_{ client .client_id } ' )
8084 logger .info (f'Socket client_id={ client .client_id } is connected' )
8185
8286 try :
@@ -89,7 +93,7 @@ async def _add_client(self, reader: asyncio.StreamReader, writer: asyncio.Stream
8993 await self .incoming_queue .put ((client .client_id , message ))
9094 # Wait for caller to potentially fill a reply queue
9195 # this should realistically never take more than a trivial amount of time
92- await asyncio .wait_for (client .yield_clear . wait ( ), timeout = 2 )
96+ await asyncio .wait_for (named_wait ( client .yield_clear , f'internal_wait_for_client_ { client . client_id } ' ), timeout = 2 )
9397 client .yield_clear .clear ()
9498 await client .send_replies ()
9599 except asyncio .TimeoutError :
0 commit comments