Skip to content

Commit

Permalink
Always update default session if session is closed (#466)
Browse files Browse the repository at this point in the history
* update default session

* update unit test

* check if default session active

Co-authored-by: Jessie Yu <[email protected]>
  • Loading branch information
kt474 and jyu00 authored Aug 17, 2022
1 parent 10ed7d0 commit 80f028c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion qiskit_ibm_runtime/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ def __init__(
if session:
self._session = session
else:
if session_pkg._DEFAULT_SESSION is None:
if (
session_pkg._DEFAULT_SESSION is None
or not session_pkg._DEFAULT_SESSION._active
):
session_pkg._DEFAULT_SESSION = Session(service=service)
self._session = session_pkg._DEFAULT_SESSION

Expand Down
5 changes: 4 additions & 1 deletion qiskit_ibm_runtime/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def __init__(
if session:
self._session = session
else:
if session_pkg._DEFAULT_SESSION is None:
if (
session_pkg._DEFAULT_SESSION is None
or not session_pkg._DEFAULT_SESSION._active
):
session_pkg._DEFAULT_SESSION = Session(service=service)
self._session = session_pkg._DEFAULT_SESSION

Expand Down

0 comments on commit 80f028c

Please sign in to comment.