| 147 | self.callback_error = None |
| 148 | |
| 149 | def poll(self): |
| 150 | self.work = 0 |
| 151 | if self.cancel is None: |
| 152 | return |
| 153 | try: |
| 154 | answer = self.cancel(self.context) |
| 155 | except BaseException as error: |
| 156 | # Identity distinguishes a callback's parser-shaped exception from |
| 157 | # a parser failure; neither its class nor message is sufficient. |
| 158 | self.callback_error = error |
| 159 | raise |
| 160 | if type(answer) is not bool: |
| 161 | raise ProfileMapInvalidArgumentError("cancel must return bool") |
| 162 | if answer: |
| 163 | raise ProfileMapCancelledError("profile map build cancelled") |
| 164 | |
| 165 | def step(self): |
| 166 | self.work += 1 |