Skip to content

Commit 0a003f3

Browse files
committed
add timeout parameter to job wait function
1 parent a727507 commit 0a003f3

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

pyvo/dal/tap.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,17 +391,19 @@ def __exit__(self, exc_type, exc_val, exc_tb):
391391
except Exception:
392392
pass
393393

394-
def _update(self, wait_for_statechange=False):
394+
def _update(self, wait_for_statechange=False, timeout=10.):
395395
"""
396396
updates local job infos with remote values
397397
"""
398398
try:
399399
if wait_for_statechange:
400-
response = s.get(self.url, stream=True, params={
401-
"WAIT": "-1"
402-
})
400+
response = s.get(
401+
self.url, stream=True, timeout=timeout, params={
402+
"WAIT": "-1"
403+
}
404+
)
403405
else:
404-
response = s.get(self.url, stream=True)
406+
response = s.get(self.url, stream=True, timeout=timeout)
405407
response.raise_for_status()
406408
except requests.RequestException as ex:
407409
raise DALServiceError.from_except(ex, self.url)
@@ -625,8 +627,7 @@ def abort(self):
625627

626628
return self
627629

628-
def wait(
629-
self, phases=None):
630+
def wait(self, phases=None, timeout=600.):
630631
"""
631632
waits for the job to reach the given phases.
632633
@@ -650,7 +651,7 @@ def wait(
650651
"QUEUED", "EXECUTING", "RUN", "COMPLETED", "ERROR", "UNKNOWN"}
651652

652653
while True:
653-
self._update(wait_for_statechange=True)
654+
self._update(wait_for_statechange=True, timeout=timeout)
654655
# use the cached value
655656
cur_phase = self._job.phase
656657

0 commit comments

Comments
 (0)