Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 910 - Added timeout to BigQuery load_job.result() #981

Closed
wants to merge 4 commits into from
Closed

Issue 910 - Added timeout to BigQuery load_job.result() #981

wants to merge 4 commits into from

Conversation

bear-jordan
Copy link

@bear-jordan bear-jordan commented Jan 27, 2024

Overview

This PR addresses Issue #910. A timeout is added to prevent indefinite hanging.

From the original issue:

Per Google BQ query job documentation, it's possible to pass a default timeout parameter to the synchronous call that awaits a response.

This change would require choosing a reasonable maximum default (30s?), setting that up as a configurable parameter, and passing that parameter into load_job.result.

Changes

27/1/2024

  • Added MAX_TIMEOUT = 30 constant
  • Updated load_job.result() to use MAX_TIMEOUT

31/1/2024 — @Jason94

  • Added max_timeout: int = 30 as a keyword argument
  • Updated load_job.result() to use max_timeout
  • Added DeadlineExceeded error handling (docs)

@@ -464,7 +467,7 @@ def copy_from_gcs(
job_config=job_config,
**load_kwargs,
)
load_job.result()
load_job.result(timeout=MAX_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a constant, perhaps this should be a keyword parameter that defaults to 30. Something like:

def get_table_ref(client, table_name, timeout = 30):

That way if 30 isn't enough for my use case, or is too long, I can adapt the behavior.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, for sure! I think that is a cleaner implementation, good suggestion

@@ -632,7 +639,10 @@ def copy_large_compressed_file_from_gcs(
job_config=job_config,
**load_kwargs,
)
load_job.result()
load_job.result(timeout=MAX_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

@bear-jordan
Copy link
Author

Hi, looked into why the Mac build is failing (see here). Github isn't reporting any outages — not too sure what is going on

Warning: Failed to download action 'https://api.github.com/repos/actions/cache/tarball/e12d46a63a90f2fae62d114769bbf2a179198b5c'. Error: Operation timed out (codeload.github.com:443)
Warning: Back off 26.77 seconds before retry.
Warning: Failed to download action 'https://api.github.com/repos/actions/cache/tarball/e12d46a63a90f2fae62d114769bbf2a179198b5c'. Error: nodename nor servname provided, or not known (codeload.github.com:443)
Warning: Back off 21.133 seconds before retry.
Error: Operation timed out (api.github.com:443)

@Jason94
Copy link
Collaborator

Jason94 commented Jan 31, 2024

Hi, looked into why the Mac build is failing (see here). Github isn't reporting any outages — not too sure what is going on

Warning: Failed to download action 'https://api.github.com/repos/actions/cache/tarball/e12d46a63a90f2fae62d114769bbf2a179198b5c'. Error: Operation timed out (codeload.github.com:443)
Warning: Back off 26.77 seconds before retry.
Warning: Failed to download action 'https://api.github.com/repos/actions/cache/tarball/e12d46a63a90f2fae62d114769bbf2a179198b5c'. Error: nodename nor servname provided, or not known (codeload.github.com:443)
Warning: Back off 21.133 seconds before retry.
Error: Operation timed out (api.github.com:443)

Sometimes this happens with these mac tests :'( I'm rerunning it and hopefully it'll pass.

@bear-jordan
Copy link
Author

Ominous that it's a timeout error 😂

@shaunagm shaunagm added the 🎉 first PR the first PR by a new contributor label Feb 22, 2024
@shaunagm
Copy link
Collaborator

Looks like the tests are passing now! What's the status of this PR? Are we waiting on re-review, or on changes?

@bear-jordan
Copy link
Author

I might have missed something, but I think all changes have been addressed.

@shaunagm
Copy link
Collaborator

Awesome! @Jason94 whenever you get a chance can you re-review?

@shaunagm shaunagm requested a review from Jason94 February 27, 2024 20:58
@bear-jordan bear-jordan closed this by deleting the head repository May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 first PR the first PR by a new contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants