diff --git a/qiskit_experiments/framework/composite/composite_analysis.py b/qiskit_experiments/framework/composite/composite_analysis.py index fb04ba50f9..0ec98eed89 100644 --- a/qiskit_experiments/framework/composite/composite_analysis.py +++ b/qiskit_experiments/framework/composite/composite_analysis.py @@ -149,12 +149,15 @@ def _run_analysis(self, experiment_data: ExperimentData): # Since copy for replace result is handled at the parent level # we always run with replace result on component analysis self._analyses[i].run(sub_expdata, replace_results=True) - - # Analysis is running in parallel so we add loop to wait - # for all component analysis to finish before returning - # the parent experiment analysis results - for sub_expdata in component_expdata: + # Block for results to avoid issues nested CompositeAnalysis runs. + # Ideally this constraint will be removed in the future. + # Previously run() was called on all components and then + # block_for_results() was called on all of them, but since only one + # thread can execute Python code at a time there is not much + # difference in performance. Blocking separately limits the number + # of threads that are started simultaneously. sub_expdata.block_for_results() + # Optionally flatten results from all component experiments # for adding to the main experiment data container if self._flatten_results: