4040 StructQueryParameter ,
4141 UDFResource ,
4242)
43- from google .cloud .bigquery .retry import DEFAULT_RETRY , DEFAULT_JOB_RETRY
43+ from google .cloud .bigquery .retry import (
44+ DEFAULT_RETRY ,
45+ DEFAULT_JOB_RETRY ,
46+ POLLING_DEFAULT_VALUE ,
47+ )
4448from google .cloud .bigquery .routine import RoutineReference
4549from google .cloud .bigquery .schema import SchemaField
4650from google .cloud .bigquery .table import _EmptyRowIterator
@@ -1437,7 +1441,7 @@ def result( # type: ignore # (incompatible with supertype)
14371441 page_size : Optional [int ] = None ,
14381442 max_results : Optional [int ] = None ,
14391443 retry : Optional [retries .Retry ] = DEFAULT_RETRY ,
1440- timeout : Optional [float ] = None ,
1444+ timeout : Optional [Union [ float , object ]] = POLLING_DEFAULT_VALUE ,
14411445 start_index : Optional [int ] = None ,
14421446 job_retry : Optional [retries .Retry ] = DEFAULT_JOB_RETRY ,
14431447 ) -> Union ["RowIterator" , _EmptyRowIterator ]:
@@ -1457,11 +1461,14 @@ def result( # type: ignore # (incompatible with supertype)
14571461 is ``DONE``, retrying is aborted early even if the
14581462 results are not available, as this will not change
14591463 anymore.
1460- timeout (Optional[float]):
1464+ timeout (Optional[Union[float, \
1465+ google.api_core.future.polling.PollingFuture._DEFAULT_VALUE, \
1466+ ]]):
14611467 The number of seconds to wait for the underlying HTTP transport
1462- before using ``retry``.
1463- If multiple requests are made under the hood, ``timeout``
1464- applies to each individual request.
1468+ before using ``retry``. If ``None``, wait indefinitely
1469+ unless an error is returned. If unset, only the
1470+ underlying API calls have their default timeouts, but we still
1471+ wait indefinitely for the job to finish.
14651472 start_index (Optional[int]):
14661473 The zero-based index of the starting row to read.
14671474 job_retry (Optional[google.api_core.retry.Retry]):
@@ -1507,6 +1514,13 @@ def result( # type: ignore # (incompatible with supertype)
15071514 # Intentionally omit job_id and query_id since this doesn't
15081515 # actually correspond to a finished query job.
15091516 )
1517+
1518+ # When timeout has default sentinel value ``object()``, do not pass
1519+ # anything to invoke default timeouts in subsequent calls.
1520+ kwargs : Dict [str , Union [_helpers .TimeoutType , object ]] = {}
1521+ if type (timeout ) is not object :
1522+ kwargs ["timeout" ] = timeout
1523+
15101524 try :
15111525 retry_do_query = getattr (self , "_retry_do_query" , None )
15121526 if retry_do_query is not None :
@@ -1548,7 +1562,7 @@ def is_job_done():
15481562 # rateLimitExceeded errors are ambiguous. We want to know if
15491563 # the query job failed and not just the call to
15501564 # jobs.getQueryResults.
1551- if self .done (retry = retry , timeout = timeout ):
1565+ if self .done (retry = retry , ** kwargs ):
15521566 # If it's already failed, we might as well stop.
15531567 job_failed_exception = self .exception ()
15541568 if job_failed_exception is not None :
@@ -1585,14 +1599,14 @@ def is_job_done():
15851599 # response from the REST API. This ensures we aren't
15861600 # making any extra API calls if the previous loop
15871601 # iteration fetched the finished job.
1588- self ._reload_query_results (retry = retry , timeout = timeout )
1602+ self ._reload_query_results (retry = retry , ** kwargs )
15891603 return True
15901604
15911605 # Call jobs.getQueryResults with max results set to 0 just to
15921606 # wait for the query to finish. Unlike most methods,
15931607 # jobs.getQueryResults hangs as long as it can to ensure we
15941608 # know when the query has finished as soon as possible.
1595- self ._reload_query_results (retry = retry , timeout = timeout )
1609+ self ._reload_query_results (retry = retry , ** kwargs )
15961610
15971611 # Even if the query is finished now according to
15981612 # jobs.getQueryResults, we'll want to reload the job status if
@@ -1682,10 +1696,10 @@ def is_job_done():
16821696 max_results = max_results ,
16831697 start_index = start_index ,
16841698 retry = retry ,
1685- timeout = timeout ,
16861699 query_id = self .query_id ,
16871700 first_page_response = first_page_response ,
16881701 num_dml_affected_rows = self ._query_results .num_dml_affected_rows ,
1702+ ** kwargs ,
16891703 )
16901704 rows ._preserve_order = _contains_order_by (self .query )
16911705 return rows
0 commit comments