prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Added retry on internal error
  Added retry on internal error as suggested by the internal error message: '500 Error encountered during execution. Retrying may solve the problem.'. 
  Rationalised the conditions structure so it would simplify addition of other retry conditions.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bigquery/google/cloud/bigquery/retry.py`
  Content:
  ```
  1 
  2 # Copyright 2018 Google LLC
  3 #
  4 # Licensed under the Apache License, Version 2.0 (the "License");
  5 # you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 #
  8 #     http://www.apache.org/licenses/LICENSE-2.0
  9 #
  10 # Unless required by applicable law or agreed to in writing, software
  11 # distributed under the License is distributed on an "AS IS" BASIS,
  12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 # See the License for the specific language governing permissions and
  14 # limitations under the License.
  15 
  16 from google.api_core import retry
  17 
  18 
  19 def _should_retry(exc):
  20     """Predicate for determining when to retry.
  21 
  22     We retry if and only if the 'reason' is 'backendError'
  23     or 'rateLimitExceeded'.
  24     """
  25     if not hasattr(exc, 'errors'):
  26         return False
  27     if len(exc.errors) == 0:
  28         return False
  29     reason = exc.errors[0]['reason']
  30     return reason == 'backendError' or reason == 'rateLimitExceeded'
  31 
  32 
  33 DEFAULT_RETRY = retry.Retry(predicate=_should_retry)
  34 """The default retry object.
  35 
  36 Any method with a ``retry`` parameter will be retried automatically,
  37 with reasonable defaults. To disable retry, pass ``retry=None``.
  38 To modify the default retry behavior, call a ``with_XXX`` method
  39 on ``DEFAULT_RETRY``. For example, to change the deadline to 30 seconds,
  40 pass ``retry=bigquery.DEFAULT_RETRY.with_deadline(30)``.
  41 """
  42
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bigquery/google/cloud/bigquery/retry.py b/bigquery/google/cloud/bigquery/retry.py
  --- a/bigquery/google/cloud/bigquery/retry.py
  +++ b/bigquery/google/cloud/bigquery/retry.py
  @@ -16,6 +16,13 @@
   from google.api_core import retry
   
   
  +_RETRYABLE_REASONS = frozenset([
  +    'backendError',
  +    'rateLimitExceeded',
  +    'internalError',
  +])
  +
  +
   def _should_retry(exc):
       """Predicate for determining when to retry.
   
  @@ -27,7 +34,7 @@
       if len(exc.errors) == 0:
           return False
       reason = exc.errors[0]['reason']
  -    return reason == 'backendError' or reason == 'rateLimitExceeded'
  +    return reason in _RETRYABLE_REASONS
   
   
   DEFAULT_RETRY = retry.Retry(predicate=_should_retry)
  
verification_info: {"golden_diff": "diff --git a/bigquery/google/cloud/bigquery/retry.py b/bigquery/google/cloud/bigquery/retry.py\n--- a/bigquery/google/cloud/bigquery/retry.py\n+++ b/bigquery/google/cloud/bigquery/retry.py\n@@ -16,6 +16,13 @@\n from google.api_core import retry\n \n \n+_RETRYABLE_REASONS = frozenset([\n+    'backendError',\n+    'rateLimitExceeded',\n+    'internalError',\n+])\n+\n+\n def _should_retry(exc):\n     \"\"\"Predicate for determining when to retry.\n \n@@ -27,7 +34,7 @@\n     if len(exc.errors) == 0:\n         return False\n     reason = exc.errors[0]['reason']\n-    return reason == 'backendError' or reason == 'rateLimitExceeded'\n+    return reason in _RETRYABLE_REASONS\n \n \n DEFAULT_RETRY = retry.Retry(predicate=_should_retry)\n", "issue": "Added retry on internal error\nAdded retry on internal error as suggested by the internal error message: '500 Error encountered during execution. Retrying may solve the problem.'. \r\nRationalised the conditions structure so it would simplify addition of other retry conditions.\n", "before_files": [{"content": "\n# Copyright 2018 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom google.api_core import retry\n\n\ndef _should_retry(exc):\n    \"\"\"Predicate for determining when to retry.\n\n    We retry if and only if the 'reason' is 'backendError'\n    or 'rateLimitExceeded'.\n    \"\"\"\n    if not hasattr(exc, 'errors'):\n        return False\n    if len(exc.errors) == 0:\n        return False\n    reason = exc.errors[0]['reason']\n    return reason == 'backendError' or reason == 'rateLimitExceeded'\n\n\nDEFAULT_RETRY = retry.Retry(predicate=_should_retry)\n\"\"\"The default retry object.\n\nAny method with a ``retry`` parameter will be retried automatically,\nwith reasonable defaults. To disable retry, pass ``retry=None``.\nTo modify the default retry behavior, call a ``with_XXX`` method\non ``DEFAULT_RETRY``. For example, to change the deadline to 30 seconds,\npass ``retry=bigquery.DEFAULT_RETRY.with_deadline(30)``.\n\"\"\"\n", "path": "bigquery/google/cloud/bigquery/retry.py"}], "after_files": [{"content": "\n# Copyright 2018 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom google.api_core import retry\n\n\n_RETRYABLE_REASONS = frozenset([\n    'backendError',\n    'rateLimitExceeded',\n    'internalError',\n])\n\n\ndef _should_retry(exc):\n    \"\"\"Predicate for determining when to retry.\n\n    We retry if and only if the 'reason' is 'backendError'\n    or 'rateLimitExceeded'.\n    \"\"\"\n    if not hasattr(exc, 'errors'):\n        return False\n    if len(exc.errors) == 0:\n        return False\n    reason = exc.errors[0]['reason']\n    return reason in _RETRYABLE_REASONS\n\n\nDEFAULT_RETRY = retry.Retry(predicate=_should_retry)\n\"\"\"The default retry object.\n\nAny method with a ``retry`` parameter will be retried automatically,\nwith reasonable defaults. To disable retry, pass ``retry=None``.\nTo modify the default retry behavior, call a ``with_XXX`` method\non ``DEFAULT_RETRY``. For example, to change the deadline to 30 seconds,\npass ``retry=bigquery.DEFAULT_RETRY.with_deadline(30)``.\n\"\"\"\n", "path": "bigquery/google/cloud/bigquery/retry.py"}]}