Skip to content

Commit 6e1d021

Browse files
dizcologyleahecole
authored andcommitted
explicitly set timeout in steaming_annotate_video, and comment [(#2182)](#2182)
1 parent b44aabe commit 6e1d021

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

videointelligence/samples/analyze/beta_snippets.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ def stream_generator():
327327
requests = stream_generator()
328328

329329
# streaming_annotate_video returns a generator.
330-
responses = client.streaming_annotate_video(requests)
330+
# The default timeout is about 300 seconds.
331+
# To process longer videos it should be set to
332+
# larger than the length (in seconds) of the stream.
333+
responses = client.streaming_annotate_video(requests, timeout=600)
331334

332335
# Each response corresponds to about 1 second of video.
333336
for response in responses:
@@ -388,7 +391,10 @@ def stream_generator():
388391
requests = stream_generator()
389392

390393
# streaming_annotate_video returns a generator.
391-
responses = client.streaming_annotate_video(requests)
394+
# The default timeout is about 300 seconds.
395+
# To process longer videos it should be set to
396+
# larger than the length (in seconds) of the stream.
397+
responses = client.streaming_annotate_video(requests, timeout=600)
392398

393399
# Each response corresponds to about 1 second of video.
394400
for response in responses:
@@ -445,7 +451,10 @@ def stream_generator():
445451
requests = stream_generator()
446452

447453
# streaming_annotate_video returns a generator.
448-
responses = client.streaming_annotate_video(requests)
454+
# The default timeout is about 300 seconds.
455+
# To process longer videos it should be set to
456+
# larger than the length (in seconds) of the stream.
457+
responses = client.streaming_annotate_video(requests, timeout=600)
449458

450459
# Each response corresponds to about 1 second of video.
451460
for response in responses:
@@ -523,7 +532,10 @@ def stream_generator():
523532
requests = stream_generator()
524533

525534
# streaming_annotate_video returns a generator.
526-
responses = client.streaming_annotate_video(requests)
535+
# The default timeout is about 300 seconds.
536+
# To process longer videos it should be set to
537+
# larger than the length (in seconds) of the stream.
538+
responses = client.streaming_annotate_video(requests, timeout=600)
527539

528540
# Each response corresponds to about 1 second of video.
529541
for response in responses:
@@ -589,7 +601,10 @@ def stream_generator():
589601
requests = stream_generator()
590602

591603
# streaming_annotate_video returns a generator.
592-
responses = client.streaming_annotate_video(requests)
604+
# The default timeout is about 300 seconds.
605+
# To process longer videos it should be set to
606+
# larger than the length (in seconds) of the stream.
607+
responses = client.streaming_annotate_video(requests, timeout=600)
593608

594609
for response in responses:
595610
# Check for errors.

0 commit comments

Comments
 (0)