@@ -663,7 +663,7 @@ def exists(self, client=None, retry=DEFAULT_RETRY):
663
663
else :
664
664
return True
665
665
666
- def reload (self , client = None , retry = DEFAULT_RETRY ):
666
+ def reload (self , client = None , retry = DEFAULT_RETRY , timeout = None ):
667
667
"""API call: refresh job properties via a GET request.
668
668
669
669
See
@@ -675,6 +675,9 @@ def reload(self, client=None, retry=DEFAULT_RETRY):
675
675
``client`` stored on the current dataset.
676
676
677
677
retry (google.api_core.retry.Retry): (Optional) How to retry the RPC.
678
+ timeout (Optional[float]):
679
+ The number of seconds to wait for the underlying HTTP transport
680
+ before retrying the HTTP request.
678
681
"""
679
682
client = self ._require_client (client )
680
683
@@ -683,7 +686,11 @@ def reload(self, client=None, retry=DEFAULT_RETRY):
683
686
extra_params ["location" ] = self .location
684
687
685
688
api_response = client ._call_api (
686
- retry , method = "GET" , path = self .path , query_params = extra_params
689
+ retry ,
690
+ method = "GET" ,
691
+ path = self .path ,
692
+ query_params = extra_params ,
693
+ timeout = timeout ,
687
694
)
688
695
self ._set_properties (api_response )
689
696
@@ -2994,9 +3001,16 @@ def estimated_bytes_processed(self):
2994
3001
result = int (result )
2995
3002
return result
2996
3003
2997
- def done (self , retry = DEFAULT_RETRY ):
3004
+ def done (self , retry = DEFAULT_RETRY , timeout = None ):
2998
3005
"""Refresh the job and checks if it is complete.
2999
3006
3007
+ Args:
3008
+ retry (Optional[google.api_core.retry.Retry]):
3009
+ How to retry the call that retrieves query results.
3010
+ timeout (Optional[float]):
3011
+ The number of seconds to wait for the underlying HTTP transport
3012
+ before retrying the HTTP request.
3013
+
3000
3014
Returns:
3001
3015
bool: True if the job is complete, False otherwise.
3002
3016
"""
@@ -3007,11 +3021,17 @@ def done(self, retry=DEFAULT_RETRY):
3007
3021
timeout_ms = None
3008
3022
if self ._done_timeout is not None :
3009
3023
# Subtract a buffer for context switching, network latency, etc.
3010
- timeout = self ._done_timeout - _TIMEOUT_BUFFER_SECS
3011
- timeout = max (min (timeout , 10 ), 0 )
3012
- self ._done_timeout -= timeout
3024
+ api_timeout = self ._done_timeout - _TIMEOUT_BUFFER_SECS
3025
+ api_timeout = max (min (api_timeout , 10 ), 0 )
3026
+ self ._done_timeout -= api_timeout
3013
3027
self ._done_timeout = max (0 , self ._done_timeout )
3014
- timeout_ms = int (timeout * 1000 )
3028
+ timeout_ms = int (api_timeout * 1000 )
3029
+
3030
+ if timeout_ms is not None and timeout_ms > 0 :
3031
+ if timeout is not None :
3032
+ timeout = min (timeout_ms , timeout )
3033
+ else :
3034
+ timeout = timeout_ms
3015
3035
3016
3036
# Do not refresh is the state is already done, as the job will not
3017
3037
# change once complete.
@@ -3022,13 +3042,14 @@ def done(self, retry=DEFAULT_RETRY):
3022
3042
project = self .project ,
3023
3043
timeout
57A7
_ms = timeout_ms ,
3024
3044
location = self .location ,
3045
+ timeout = timeout ,
3025
3046
)
3026
3047
3027
3048
# Only reload the job once we know the query is complete.
3028
3049
# This will ensure that fields such as the destination table are
3029
3050
# correctly populated.
3030
3051
if self ._query_results .complete :
3031
- self .reload (retry = retry )
3052
+ self .reload (retry = retry , timeout = timeout )
3032
3053
3033
3054
return self .state == _DONE_STATE
3034
3055
0 commit comments