Skip to content

Commit 78c08bc

Browse files
anguillanneufplamut
authored andcommitted
Pub/Sub: add timeout in argparse [(#2637)](GoogleCloudPlatform/python-docs-samples#2637)
1 parent 4792193 commit 78c08bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

samples/snippets/subscriber.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,17 +484,24 @@ def callback(message):
484484
"receive", help=receive_messages.__doc__
485485
)
486486
receive_parser.add_argument("subscription_name")
487+
receive_parser.add_argument("--timeout", default=None, type=float)
487488

488489
receive_with_custom_attributes_parser = subparsers.add_parser(
489490
"receive-custom-attributes",
490491
help=receive_messages_with_custom_attributes.__doc__,
491492
)
492493
receive_with_custom_attributes_parser.add_argument("subscription_name")
494+
receive_with_custom_attributes_parser.add_argument(
495+
"--timeout", default=None, type=float
496+
)
493497

494498
receive_with_flow_control_parser = subparsers.add_parser(
495499
"receive-flow-control", help=receive_messages_with_flow_control.__doc__
496500
)
497501
receive_with_flow_control_parser.add_argument("subscription_name")
502+
receive_with_flow_control_parser.add_argument(
503+
"--timeout", default=None, type=float
504+
)
498505

499506
synchronous_pull_parser = subparsers.add_parser(
500507
"receive-synchronously", help=synchronous_pull.__doc__
@@ -513,6 +520,9 @@ def callback(message):
513520
"listen_for_errors", help=listen_for_errors.__doc__
514521
)
515522
listen_for_errors_parser.add_argument("subscription_name")
523+
listen_for_errors_parser.add_argument(
524+
"--timeout", default=None, type=float
525+
)
516526

517527
args = parser.parse_args()
518528

0 commit comments

Comments
 (0)