Get the result, waiting and decoding as needed.
(self)
| 919 | return self._result[key] |
| 920 | |
| 921 | def _load_result(self): |
| 922 | """Get the result, waiting and decoding as needed.""" |
| 923 | if self._result is None: |
| 924 | # Wait for the query response |
| 925 | self.wait(timeout=None) |
| 926 | |
| 927 | # Check for other error conditions |
| 928 | if self._exception is not None: |
| 929 | raise self._exception |
| 930 | |
| 931 | with self._result_write_lock: |
| 932 | # If someone else took care of decoding while we were waiting |
| 933 | if self._result is not None: |
| 934 | return self._result |
| 935 | |
| 936 | # extract results from the response |
| 937 | # note: decoding might mutate `self._message`, so it should be only called once |
| 938 | self._decode() |
| 939 | |
| 940 | # signal answer data downloaded |
| 941 | if 'answer' in self._result: |
| 942 | self._answer_data_ready_event.set() |
| 943 | |
| 944 | # create a direct reference to sampleset if already available in response |
| 945 | # NB: in this case we don't actually need a weakref (strong ref is fine), |
| 946 | # but we use it for consistency |
| 947 | if 'sampleset' in self._result: |
| 948 | # add common problem info |
| 949 | sampleset = self._result['sampleset'] |
| 950 | sampleset.info.update(self._get_problem_info()) |
| 951 | |
| 952 | self._sampleset = weakref.ref(sampleset) |
| 953 | |
| 954 | return self._result |
| 955 | |
| 956 | def _get_problem_info(self): |
| 957 | """Return problem metadata (id, label) to be included in `sampleset.info`.""" |
no test coverage detected