@@ -305,20 +305,31 @@ async def wait(self, t: Union[int, float] = None):
305305 await self .update_target ()
306306 loop = asyncio .get_running_loop ()
307307 start_time = loop .time ()
308- try :
309- if isinstance (t , (int , float )):
310- await asyncio .wait_for (self .listener .idle .wait (), timeout = t )
311- while (loop .time () - start_time ) < t :
312- await asyncio .sleep (0.1 )
313- else :
314- await self .listener .idle .wait ()
315- except asyncio .TimeoutError :
316- if isinstance (t , (int , float )):
317- # Explicit time is given, which is now passed, so leave now.
318- return
319- except AttributeError :
320- # No listener created yet.
321- pass
308+ with warnings .catch_warnings ():
309+ warnings .filterwarnings (
310+ action = "ignore" ,
311+ category = RuntimeWarning ,
312+ message = ".*coroutine.*" ,
313+ )
314+ try :
315+ if isinstance (t , (int , float )):
316+ try :
317+ await asyncio .wait_for (
318+ self .listener .idle .wait (), timeout = t
319+ )
320+ except RuntimeError :
321+ await self .listener .idle .wait ()
322+ while (loop .time () - start_time ) < t :
323+ await asyncio .sleep (0.1 )
324+ else :
325+ await self .listener .idle .wait ()
326+ except asyncio .TimeoutError :
327+ if isinstance (t , (int , float )):
328+ # Explicit time that's given has passed, so leave now.
329+ return
330+ except AttributeError :
331+ # No listener created yet.
332+ pass
322333
323334 async def set_locale (self , locale : Optional [str ] = None ):
324335 """Sets the Language Locale code via set_user_agent_override."""
@@ -423,9 +434,9 @@ async def send(
423434 await self .websocket .send (tx .message )
424435 with warnings .catch_warnings ():
425436 warnings .filterwarnings (
426- "ignore" ,
427- message = "coroutine .* was never awaited" ,
437+ action = "ignore" ,
428438 category = RuntimeWarning ,
439+ message = ".*coroutine.*" ,
429440 )
430441 try :
431442 return await tx
0 commit comments