You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
isinstance(someinteger, object) called like that is always True, because int is an instance of an object:
>>> isinstance(3, object)
True
As a result, the timeout is always changed to None at this point. This causes timeout to not be respected when for example QueryJob.exception method is called.
Reacted by Marcel Ślimak, Tomasz Michalski and Rafał Fiedosiuk
Thank you @jacek-jablonski for raising this issue! To ensure that I can reproduce the exact problem, could you provide a code snippet? This way I can add a unit test for this case.
importconcurrent.futuresimportpytestfromgoogle.cloudimportbigqueryTEST_SLEEP_QUERY="""BEGIN DECLARE DELAY_TIME DATETIME; DECLARE WAIT STRING; SET WAIT = 'TRUE'; SET DELAY_TIME = DATETIME_ADD(CURRENT_DATETIME, INTERVAL {seconds} SECOND); WHILE WAIT = 'TRUE' DO IF (DELAY_TIME < CURRENT_DATETIME) THEN SET WAIT = 'FALSE'; END IF; END WHILE;END;"""deftest_query_timeout():
client=bigquery.Client()
query_job=client.query(TEST_SLEEP_QUERY.format(seconds=10))
withpytest.raises(concurrent.futures.TimeoutError):
query_job.exception(timeout=1)
Thank you @jacek-jablonski. I tried out the sample, and although the value of self._done_timeout was indeed wiped out into None, but it doesn't seem to do anything - if I set query_job.exception(timeout=1), I get a timeout error; if I set query_job.exception(timeout=100), I don't get any error. Am I missing something here? What is the expected behavior?
======================================================= FAILURES =======================================================
__________________________________________________ test_query_timeout __________________________________________________
def test_query_timeout():
client = bigquery.Client()
query_job = client.query(TEST_SLEEP_QUERY.format(seconds=10))
> with pytest.raises(concurrent.futures.TimeoutError):
E Failed: DID NOT RAISE <class 'TimeoutError'>
test_bq.py:28: Failed
=============================================== short test summary info ================================================
FAILED test_bq.py::test_query_timeout - Failed: DID NOT RAISE <class 'TimeoutError'>
================================================== 1 failed in 12.20s ==================================================
and passes on v3.11.2:
test_bq.py . [100%]
================================================== 1 passed in 3.12s ===================================================
api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
Linchin commentedon Mar 5, 2024
Thank you @jacek-jablonski for raising this issue! To ensure that I can reproduce the exact problem, could you provide a code snippet? This way I can add a unit test for this case.
jacek-jablonski commentedon Mar 6, 2024
Hi @Linchin,
here is a code snippet:
Linchin commentedon Mar 6, 2024
Thank you @jacek-jablonski. I tried out the sample, and although the value of
self._done_timeoutwas indeed wiped out intoNone, but it doesn't seem to do anything - if I setquery_job.exception(timeout=1), I get a timeout error; if I setquery_job.exception(timeout=100), I don't get any error. Am I missing something here? What is the expected behavior?jacek-jablonski commentedon Mar 7, 2024
Hi @Linchin,
for me, this test fails on
v3.18.0:and passes on
v3.11.2:Linchin commentedon Mar 7, 2024
I'm still unable to reproduce the issue - could you let me know which version of python you are using, and possibly the versions of your dependencies?
jacek-jablonski commentedon Mar 8, 2024
I recorded a screencast:
Nagranie.z.ekranu.2024-03-8.o.09.21.23.mp4
Below some more information.
Python version:
3.11.7Pip freeze when v3.18.0 is installed:
Pip freeze when v3.11.2 is installed:
Linchin commentedon Mar 8, 2024
Thanks @jacek-jablonski! I'm finally able to reproduce it in python 3.11. Let me take a deeper look into it.
Linchin commentedon Mar 8, 2024
It's also flaky with python 3.11 - sometimes the exception is raised, sometimes it's not. Regardless I will fix the type check first.
fix: correct type checking (#1848)