Comments (3)
That's a tricky one. Nailed it down as below and will continue the investigation early next week.
good-case.py
from requests import Session
class CustomSession(Session):
def __del__(self) -> None:
self.close()
session = CustomSession()
result = session.get("https://auth.quantum-computing.ibm.com/api/version").json()
print(result)
bad-case.py
from qiskit_ibm_runtime.api.session import RetrySession
session = RetrySession(
base_url="https://auth.quantum-computing.ibm.com",
auth=None,
)
# TypeError only seen when a request is made
result = session.get("/api/version").json()
print(result)
Running python good-case.py
succeeds, while python bad-case.py
fails with the reported TypeError. I.e. something within RetrySession
must be the culprit...
from qiskit-ibm-runtime.
Investigation Results
Observations
- Code fragment that is causing
TypeError: catching classes that do not inherit from BaseException
. In the failing case,queue.Empty
is None.
# File ".../site-packages/urllib3/connectionpool.py", line 494, in close
def close(self):
# ...
-> except queue.Empty:
pass
- Entrypoint from code within
qiskit-ibm-runtime
that leads to the exception:
# File ".../qiskit_ibm_runtime/api/session.py", line 173, in __del__
class RetrySession(Session):
def __del__(self) -> None:
-> self.close()
- To debug this further I instrumented the custom session code with a print statement as shown below.
import queue
class CustomSession(Session):
def __del__(self) -> None:
print("CustomSession#__del__", queue.Empty)
self.close()
# output in success case: CustomSession#__del__ <class '_queue.Empty'>
# output in failing case: RetrySession#__del__ None
Conclusions
Our code calls session cleanup code from within the destructor of a custom session subclass. The destructor (__del__
) is called when the object is destroyed. At this point in time it can apparently happen that queue.Empty
returns None
. Maybe because Python has cleaned up other objects as well.
I can't find any references which indicate that triggering the cleanup of session information from within the destructor is a supported best practice. At the same time we can't switch to using a session context manager without breaking the APIs that consumers are used to.
Proposed Solution
Ignore errors and do not spend additional time understanding how python cleans up module references under the covers (see #103)
from qiskit-ibm-runtime.
With #103 the "high priority" part of this issue has been addressed.
Based on the above investigation we can reprioritize the work and come up with a proper fix in a next step. Need a second pair of eyes to help with that and think about clean solutions (cc: @rathishcholarajan)
from qiskit-ibm-runtime.
Related Issues (20)
- Failing integration test `test_too_many_qubits_in_circuit`
- IBMNotAuthorizedError: '401 Client Error: Unauthorized for url: https://auth.quantum-computing.ibm.com/api/users/loginWithToken. Login with some authorized provider required., Error code: 3445.' HOT 1
- Precision and shots are not consistent for EstimatorV2 HOT 1
- Variances for non-commuting observables are wrong
- Use attribute docstrings for options
- Move backend related modules from Qiskit HOT 1
- There are no e2e tests
- Unit tests failing against main branch of Qiskit
- Deprecate interim result streaming
- Remove the use of websocket for job status
- A faulty qubit in FakeHanoi
- Deprecate passing a string for backend
- JSON Error when retrieving job results HOT 1
- Allow retrieving all backend data HOT 1
- Add private job attribute
- An user should have an easy way to verify a circuit is compatible with a target backend HOT 1
- race condition in list pending jobs integration test
- Validate precision values in `estimator.run()`
- Provide a usage function on RuntimeJob so metrics don't have to be parsed HOT 1
- Add `EstimatorPubResult` with plotting methods
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qiskit-ibm-runtime.