File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,18 +12,17 @@ def main() -> None:
1212 try :
1313 # Telemetry is a default direct-to-VM routing subresource, so the stream
1414 # connects straight to the browser VM automatically.
15- stream = client .browsers .telemetry .stream (browser .session_id )
16-
1715 # Make a few browser activity calls to generate events. The "api" telemetry
1816 # category emits an event per VM API call, so events arrive within ~1s.
1917 for _ in range (3 ):
2018 client .browsers .curl (browser .session_id , url = "https://example.com" , method = "GET" )
2119
2220 # Print a few events, then stop so we don't wait on the 15s keepalive.
23- for count , message in enumerate (stream , start = 1 ):
24- print (message .seq , message .event .type )
25- if count >= 3 :
26- break
21+ with client .browsers .telemetry .stream (browser .session_id ) as stream :
22+ for count , message in enumerate (stream , start = 1 ):
23+ print (message .seq , message .event .type )
24+ if count >= 3 :
25+ break
2726 finally :
2827 client .browsers .delete_by_id (browser .session_id )
2928
You can’t perform that action at this time.
0 commit comments