Python google.api_core.exceptions.DeadlineExceeded() Examples
The following are 13
code examples of google.api_core.exceptions.DeadlineExceeded().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
google.api_core.exceptions
, or try the search function
.
Example #1
Source File: system.py From python-pubsub with Apache License 2.0 | 6 votes |
def test_synchronous_pull_no_deadline_error_if_no_messages( publisher, topic_path, subscriber, subscription_path, cleanup ): # Make sure the topic and subscription get deleted. cleanup.append((publisher.delete_topic, topic_path)) cleanup.append((subscriber.delete_subscription, subscription_path)) # Create a topic and subscribe to it. publisher.create_topic(topic_path) subscriber.create_subscription(subscription_path, topic_path) try: response = subscriber.pull(subscription_path, max_messages=2) except core_exceptions.DeadlineExceeded: pytest.fail( "Unexpected DeadlineExceeded error on synchronous pull when no " "messages published to the topic." ) else: assert list(response.received_messages) == []
Example #2
Source File: snippets_test.py From python-docs-samples with Apache License 2.0 | 6 votes |
def test_update_uptime_config(capsys): # create and delete happen in uptime fixture. new_display_name = random_name(10) new_uptime_check_path = '/' + random_name(10) with UptimeFixture() as fixture: # We sometimes see the permission error saying the resource # may not exist. Weirdly DeadlineExceeded instnace is raised # in this case. @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=120) def call_sample(): snippets.update_uptime_check_config( fixture.config.name, new_display_name, new_uptime_check_path) call_sample() out, _ = capsys.readouterr() snippets.get_uptime_check_config(fixture.config.name) out, _ = capsys.readouterr() assert new_display_name in out assert new_uptime_check_path in out
Example #3
Source File: translate_v3_batch_translate_text_with_glossary_test.py From python-docs-samples with Apache License 2.0 | 6 votes |
def glossary(): """Get the ID of a glossary available to session (do not mutate/delete).""" glossary_id = "test-{}".format(uuid.uuid4()) translate_v3_create_glossary.create_glossary( PROJECT_ID, GLOSSARY_INPUT_URI, glossary_id ) yield glossary_id # cleanup @backoff.on_exception( backoff.expo, (DeadlineExceeded, GoogleAPICallError), max_time=60 ) def delete_glossary(): try: translate_v3_delete_glossary.delete_glossary( PROJECT_ID, glossary_id) except NotFound as e: # Ignoring this case. print("Got NotFound, detail: {}".format(str(e))) delete_glossary()
Example #4
Source File: translate_v3_get_glossary_test.py From python-docs-samples with Apache License 2.0 | 6 votes |
def glossary(): """Get the ID of a glossary available to session (do not mutate/delete).""" glossary_id = "must-start-with-letters-" + str(uuid.uuid1()) translate_v3_create_glossary.create_glossary( PROJECT_ID, GLOSSARY_INPUT_URI, glossary_id ) yield glossary_id # cleanup @backoff.on_exception( backoff.expo, (DeadlineExceeded, GoogleAPICallError), max_time=60 ) def delete_glossary(): try: translate_v3_delete_glossary.delete_glossary( PROJECT_ID, glossary_id) except NotFound as e: # Ignoring this case. print("Got NotFound, detail: {}".format(str(e))) delete_glossary()
Example #5
Source File: translate_v3_translate_text_with_glossary_test.py From python-docs-samples with Apache License 2.0 | 6 votes |
def glossary(): """Get the ID of a glossary available to session (do not mutate/delete).""" glossary_id = "must-start-with-letters-" + str(uuid.uuid1()) translate_v3_create_glossary.create_glossary( PROJECT_ID, GLOSSARY_INPUT_URI, glossary_id ) yield glossary_id # cleanup @backoff.on_exception( backoff.expo, (DeadlineExceeded, GoogleAPICallError), max_time=60 ) def delete_glossary(): try: translate_v3_delete_glossary.delete_glossary( PROJECT_ID, glossary_id) except NotFound as e: # Ignoring this case. print("Got NotFound, detail: {}".format(str(e))) delete_glossary()
Example #6
Source File: translate_v3_create_glossary_test.py From python-docs-samples with Apache License 2.0 | 6 votes |
def test_create_glossary(capsys): try: glossary_id = "test-{}".format(uuid.uuid4()) translate_v3_create_glossary.create_glossary( PROJECT_ID, GLOSSARY_INPUT_URI, glossary_id ) out, _ = capsys.readouterr() # assert assert "Created:" in out assert "gs://cloud-samples-data/translation/glossary_ja.csv" in out finally: # cleanup @backoff.on_exception( backoff.expo, (DeadlineExceeded, GoogleAPICallError), max_time=60 ) def delete_glossary(): try: translate_v3_delete_glossary.delete_glossary( PROJECT_ID, glossary_id) except NotFound as e: # Ignoring this case. print("Got NotFound, detail: {}".format(str(e))) delete_glossary()
Example #7
Source File: pubsub.py From stoq-plugins-public with Apache License 2.0 | 6 votes |
def ingest(self, queue: Queue) -> None: topic = f'projects/{self.project_id}/topics/{self.topic}' subscription = f'projects/{self.project_id}/subscriptions/{self.subscription}' self._ingest_connect(subscription, topic) self.log.info(f'Monitoring {subscription} subscription for messages...') while True: try: messages = self.ingest_client.pull( subscription, max_messages=self.max_messages, return_immediately=False, ) for msg in messages.received_messages: await queue.put(json.loads(msg.message.data.decode())) self.ingest_client.acknowledge(subscription, [msg.ack_id]) except DeadlineExceeded: self.log.debug( f'Reconnecting to {subscription} subscription for messages...' ) self._ingest_connect(subscription, topic)
Example #8
Source File: test_query.py From python-ndb with Apache License 2.0 | 5 votes |
def test_fetch_w_absurdly_short_timeout(ds_entity): for i in range(5): entity_id = test_utils.system.unique_resource_id() ds_entity(KIND, entity_id, foo=i) class SomeKind(ndb.Model): foo = ndb.IntegerProperty() query = SomeKind.query() timeout = 1e-9 # One nanosecend with pytest.raises(Exception) as error_context: query.fetch(timeout=timeout) assert isinstance(error_context.value, core_exceptions.DeadlineExceeded)
Example #9
Source File: writes_test.py From python-docs-samples with Apache License 2.0 | 5 votes |
def test_writes(capsys, table_id): # `row.commit()` sometimes ends up with DeadlineExceeded, so now # we put retries with a hard deadline. @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60) def _write_simple(): write_simple(PROJECT, BIGTABLE_INSTANCE, table_id) _write_simple() out, _ = capsys.readouterr() assert 'Successfully wrote row' in out @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60) def _write_increment(): write_increment(PROJECT, BIGTABLE_INSTANCE, table_id) _write_increment() out, _ = capsys.readouterr() assert 'Successfully updated row' in out @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60) def _write_conditional(): write_conditional(PROJECT, BIGTABLE_INSTANCE, table_id) _write_conditional() out, _ = capsys.readouterr() assert 'Successfully updated row\'s os_name' in out @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60) def _write_batch(): write_batch(PROJECT, BIGTABLE_INSTANCE, table_id) _write_batch() out, _ = capsys.readouterr() assert 'Successfully wrote 2 rows' in out
Example #10
Source File: snippets_test.py From python-docs-samples with Apache License 2.0 | 5 votes |
def retry_on_exceptions(exception): return isinstance( exception, (Aborted, ServiceUnavailable, DeadlineExceeded))
Example #11
Source File: vision_object_detection_predict_test.py From python-docs-samples with Apache License 2.0 | 5 votes |
def test_vision_object_detection_predict(capsys, verify_model_state): file_path = "resources/salad.jpg" # Retry the sample upon DeadlineExceeded, with a hard deadline of 5 mins. @backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=300) def run_sample(): vision_object_detection_predict.predict(PROJECT_ID, MODEL_ID, file_path) run_sample() out, _ = capsys.readouterr() assert "Predicted class name:" in out
Example #12
Source File: test_retry.py From gapic-generator-python with Apache License 2.0 | 5 votes |
def test_retry_bubble(echo): with pytest.raises(exceptions.DeadlineExceeded): echo.echo({ 'error': { 'code': code_pb2.Code.Value('DEADLINE_EXCEEDED'), 'message': 'This took longer than you said it should.', }, })
Example #13
Source File: test_retry.py From gapic-generator-python with Apache License 2.0 | 5 votes |
def test_retry_bubble_async(async_echo): with pytest.raises(exceptions.DeadlineExceeded): await async_echo.echo({ 'error': { 'code': code_pb2.Code.Value('DEADLINE_EXCEEDED'), 'message': 'This took longer than you said it should.', }, })