1717import math
1818import uuid
1919from asyncio .tasks import Task
20- from typing import Any , Callable , List , Optional , Tuple , Union
20+ from typing import Any , Callable , Dict , List , Optional , Tuple , Union
2121
2222from pyee import EventEmitter
2323
@@ -37,9 +37,7 @@ def __init__(self, channel_owner: ChannelOwner, event: str) -> None:
3737 self ._wait_for_event_info_before (self ._wait_id , event )
3838
3939 def _wait_for_event_info_before (self , wait_id : str , event : str ) -> None :
40- self ._channel .send_no_reply (
41- "__waitInfo__" ,
42- None ,
40+ self ._send_wait_for_event_info (
4341 {
4442 "waitId" : wait_id ,
4543 "phase" : "before" ,
@@ -49,18 +47,29 @@ def _wait_for_event_info_before(self, wait_id: str, event: str) -> None:
4947 )
5048
5149 def _wait_for_event_info_after (self , wait_id : str , error : Exception = None ) -> None :
52- self ._channel ._connection .wrap_api_call_sync (
53- lambda : self ._channel .send_no_reply (
50+ self ._send_wait_for_event_info (
51+ {
52+ "waitId" : wait_id ,
53+ "phase" : "after" ,
54+ ** ({"error" : str (error )} if error else {}),
55+ },
56+ is_internal = True ,
57+ )
58+
59+ def _send_wait_for_event_info (
60+ self , params : Dict [str , Any ], is_internal : bool = False , title : str = None
61+ ) -> None :
62+ # Wait info is fire-and-forget telemetry and must not affect the waiter.
63+ try :
64+ self ._channel .send_no_reply (
5465 "__waitInfo__" ,
5566 None ,
56- {
57- "waitId" : wait_id ,
58- "phase" : "after" ,
59- ** ({"error" : str (error )} if error else {}),
60- },
61- ),
62- True ,
63- )
67+ params ,
68+ is_internal = is_internal ,
69+ title = title ,
70+ )
71+ except Error :
72+ pass
6473
6574 def reject_on_event (
6675 self ,
@@ -159,21 +168,14 @@ def result(self) -> asyncio.Future:
159168
160169 def log (self , message : str ) -> None :
161170 self ._logs .append (message )
162- try :
163- self ._channel ._connection .wrap_api_call_sync (
164- lambda : self ._channel .send_no_reply (
165- "__waitInfo__" ,
166- None ,
167- {
168- "waitId" : self ._wait_id ,
169- "phase" : "log" ,
170- "message" : message ,
171- },
172- ),
173- True ,
174- )
175- except Exception :
176- pass
171+ self ._send_wait_for_event_info (
172+ {
173+ "waitId" : self ._wait_id ,
174+ "phase" : "log" ,
175+ "message" : message ,
176+ },
177+ is_internal = True ,
178+ )
177179
178180
179181def throw_on_timeout (timeout : float , exception : Exception ) -> asyncio .Task :
0 commit comments