Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Added close_session #762

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Changes from 3 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
10 changes: 10 additions & 0 deletions qiskit_ibm_provider/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,16 @@ def session(self) -> Session:

def cancel_session(self) -> None:
"""Cancel session. All pending jobs will be cancelled."""
if self._session:
self._session.cancel()
if self._session.session_id:
self.provider._runtime_client.cancel_session(self._session.session_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.provider._runtime_client.cancel_session doesn't exist in this repo so it'll have to be added there as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I shouldn't have submitted for review so quickly. I copied the implementation from runtime. Also added a test, though it is pretty trivial. We will unite this functionality back when uniting the two repos.

self._session = None

def close_session(self) -> None:
"""Close the session so new jobs will no longer be accepted, but existing
queued or running jobs will run to completion. The session will be terminated once there
are no more pending jobs."""
if self._session:
self._session.cancel()
if self._session.session_id:
Expand Down
Loading