Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.. release-notes:: Release Notes
:version: 0.4.0, 0.3.0, 0.2.0, 0.1.0, 0.1.0rc2, 0.1.0rc1
14 changes: 13 additions & 1 deletion qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""Qiskit runtime job."""

from typing import Any, Optional, Callable, Dict, Type
import time
import logging
from concurrent import futures
import traceback
Expand Down Expand Up @@ -232,13 +233,24 @@ def wait_for_final_state(self, timeout: Optional[float] = None) -> None:
RuntimeJobTimeoutError: If the job does not complete within given timeout.
"""
try:
start_time = time.time()
if self._status not in JOB_FINAL_STATES and not self._is_streaming():
self._ws_client_future = self._executor.submit(
self._start_websocket_client
)
if self._is_streaming():
self._ws_client_future.result(timeout)
self.status()
# poll for status after stream has closed until status is final
# because status doesn't become final as soon as stream closes
status = self.status()
while status not in JOB_FINAL_STATES:
elapsed_time = time.time() - start_time
if timeout is not None and elapsed_time >= timeout:
raise RuntimeJobTimeoutError(
f"Timed out waiting for job to complete after {timeout} secs."
)
time.sleep(3)
status = self.status()
except futures.TimeoutError:
raise RuntimeJobTimeoutError(
f"Timed out waiting for job to complete after {timeout} secs."
Expand Down