diff --git a/qiskit/providers/ibmq/random/ibmqrandomservice.py b/qiskit/providers/ibmq/random/ibmqrandomservice.py index 54e84c076..445fa0973 100644 --- a/qiskit/providers/ibmq/random/ibmqrandomservice.py +++ b/qiskit/providers/ibmq/random/ibmqrandomservice.py @@ -110,7 +110,8 @@ def __dir__(self) -> Dict: return self.__dict__ def __getattr__(self, item: str) -> Any: - self._discover_services() + if not self.__getattribute__('_initialized'): + self._discover_services() try: return self._services[item] except KeyError: diff --git a/releasenotes/notes/random-loop-85cc24a9ac024a8f.yaml b/releasenotes/notes/random-loop-85cc24a9ac024a8f.yaml new file mode 100644 index 000000000..a9adbcb06 --- /dev/null +++ b/releasenotes/notes/random-loop-85cc24a9ac024a8f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes the infinite loop raised when passing an ``IBMQRandomService`` instance + to a child process.