qiskit-ibm-runtime
qiskit-ibm-runtime copied to clipboard
close_all_sessions()
What is the expected feature or enhancement? A method that closes any currently open sessions.
For example, say I am developing code that involves submitting jobs in a session. I run the code and it starts submitting jobs. Then I notice a bug in my code, so I hit ctrl+C to interrupt, fix the bug, then restart. If I understand correctly, a new session is created, but the old session is still running and I cannot close it since I do not have access to it. Instead, I have to wait for some timeout condition to automatically kill the old session before my new session can start running jobs (is this correct?).
If the above is an accurate description of the situation, then if I could call service.close_all_sessions()
, I would not have to wait for this timeout condition. More generally, it would also be nice to have access to something like service.open_sessions()
so I can see a list of what sessions I have open (and potentially close unneeded ones).
I second this. Perhaps with an optional filter for a specific backend.
I've been using Runtime pretty regularly for the past few weeks. A more common case where this can come up is when you run a cell in a Jupyter notebook like:
session = Session(...)
[run the jobs]
The jobs run, and based on the data (or errors 😅) you get back, you want to make a small tweak and try again. So you run the cell again. But (if I understand correctly) it can't run the jobs yet because the old session
is still open. And the line session = Session(...)
has erased your reference to the old session, so you can't close it. So now you have to wait around for 5 minutes until the old session times out. In this situation, a way to close the old session could be very helpful.
I agree this would be a nice feature. Probably will need to wait for https://github.com/Qiskit/qiskit-ibm-runtime/issues/887 first though, so we know which sessions are actually active.
Seconding this as a good feature to have