Skip to content

Commit 0dada49

Browse files
authored
Merge pull request #743 from stvoutsin/fix-phase-cached
FIX: raise_if_error() to use cached job phase instead of re-polling
2 parents f848924 + 9574eba commit 0dada49

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Enhancements and Fixes
55
----------------------
66

7+
- Fix raise_if_error() to use cached job phase instead of re-polling [#743]
8+
79
- Add ``pyvo.registry.get_RegTAP_service_url()`` to allow users to inspect the
810
currently configured registry endpoint. Expose other user-facing constants at their package level. [#742]
911

pyvo/dal/tap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,9 @@ def raise_if_error(self):
10451045
DALQueryError
10461046
if theres an error
10471047
"""
1048-
if self.phase in {"ERROR", "ABORTED"}:
1048+
if self._job.phase in {"ERROR", "ABORTED"}:
10491049
msg = ""
1050-
if self._job and self._job.errorsummary:
1050+
if self._job.errorsummary:
10511051
msg = self._job.errorsummary.message.content
10521052
msg = msg or "<No useful error from server>"
10531053
raise DALQueryError("Query Error: " + msg, self.url)

pyvo/dal/tests/test_tap.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,16 @@ def test_erroneus_submit_job(self):
617617
job.raise_if_error()
618618
assert 'test_erroneus_submit.non_existent not found' in str(e)
619619

620+
def test_raise_if_error_uses_cached_phase(self, async_fixture):
621+
matchers = async_fixture
622+
service = TAPService('http://example.com/tap')
623+
job = service.submit_job(
624+
"SELECT * FROM test_erroneus_submit.non_existent")
625+
call_count_before = matchers["job"].call_count
626+
with pytest.raises(DALQueryError):
627+
job.raise_if_error()
628+
assert call_count_before == matchers["job"].call_count
629+
620630
@pytest.mark.usefixtures('async_fixture')
621631
def test_submit_job_case(self):
622632
"""Test using mixed case in the QUERY parameter to a job.

0 commit comments

Comments
 (0)